showing an alert message after submit
<p>I'm having a problem showing an alert message after submitting a form.
I have a form for submitting a report, then after submission it will be stored in a table. What I want to happen is that after submitting a report, there will be an alert message for each new submitted report. I'm using CI as framework. Here is what I have: </p>

<p><strong>View:</strong></p>

<pre><code>&lt;div class="row-fluid"&gt;
                    &lt;button type="button" class="btn btn-primary col-lg-2" data-toggle="collapse" data-target="#add_form" onclick="add_clicked()"&gt;Submit Report&lt;/button&gt;&lt;br /&gt;

                &lt;div class="col-lg-6"&gt;
                    &lt;?php
                    $attributes = array('class' =&gt; $class, 'id' =&gt; 'add_form', 'role' =&gt; 'form');
                    echo form_open('admin/report', $attributes);?&gt;
                    &lt;div class="form-group"&gt;
                        &lt;input class="form-control" type="hidden" name="add_hidden" value="add-report"&gt;
                    &lt;/div&gt;
                    &lt;br&gt;&lt;br&gt;
                    &lt;div class="form-group"&gt;
                        &lt;?=form_input( array('id'=&gt;'sender','class'=&gt;'form-control' ,'name'=&gt;'sender','type'=&gt;'text','placeholder'=&gt; 'Senders Name', 'value' =&gt; set_value('sender'), 'required'=&gt; 'true') );?&gt; &lt;br /&gt;
                        &lt;?=form_input( array('id'=&gt;'date','class'=&gt;'form-control date-picker','name'=&gt;'date','type'=&gt;'text','placeholder'=&gt; 'Date', 'value' =&gt; set_value('date') ) );
                        $date = date('Y-m-d H:i:s');?&gt;&lt;br /&gt;
                        &lt;?=form_textarea( array('id'=&gt;'subject','class'=&gt;'form-control','name'=&gt;'subject','type'=&gt;'message-text','placeholder'=&gt; 'Your Message here', 'value' =&gt; set_value('subject'), 'required'=&gt; 'true') );?&gt;&lt;br /&gt;


                    &lt;/div&gt;
                    &lt;div class="form-group"&gt;
                        &lt;?=form_input( array('class'=&gt;'btn btn-success','id'=&gt;'add_submit','type'=&gt;'submit','value'=&gt;'submit')) ;?&gt;
                    &lt;/div&gt;
                    &lt;?=form_close();?&gt;
                &lt;/div&gt;
                &lt;div class="col-md-10 text-center" id="success" style="display:none"&gt;
                    &lt;?php if(isset($message)) echo $message ?&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;br&gt; &lt;br&gt;
        &lt;div class="table-responsive"&gt;
            &lt;table class="table table-hover table-striped"&gt;
                &lt;thead&gt;
                &lt;tr&gt;
                    &lt;th style="text-align: center"&gt;Sender&lt;/th&gt;
                    &lt;th style="text-align:center"&gt;Subject&lt;/th&gt;
                    &lt;th style="text-align:center"&gt;Date&lt;/th&gt;


                &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;
                &lt;?php
                foreach ($query-&gt;result_array() as $row) {

                    echo '
                                                                    &lt;tr&gt;
                                                                            &lt;td style="text-align:center"&gt;'.$row["sender"].'&lt;/td&gt;
                                                                            &lt;td style="text-align:center"&gt;'.$row["subject"].'&lt;/td&gt;
                                                                            &lt;td style="text-align:center"&gt;'.$row["date"].'&lt;/td&gt;

                                                                    &lt;td&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;button type="button" class="btn btn-success btn-small" data-toggle="modal" data-target="#view'.$row["sender"].'"&gt; Read &lt;/button&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;
                                                                            &lt;button type="button" class="btn btn-danger btn-small" data-toggle="modal" data-target="#remove'.$row["sender"].'"&gt;delete&lt;/button&gt;&lt;/td&gt;


                                                                    &lt;/tr&gt;




                                                                    ';
                }
                ?&gt;
</code></pre>

<p><strong>This is my controller:</strong></p>

<pre><code>public function report()
    {
        $this-&gt;load-&gt;model('report_model', 'database');
        $sql = "SELECT * FROM report";
        $data['query'] = $this-&gt;database-&gt;view_report($sql);

    if ($this-&gt;input-&gt;post('add_hidden')) {
        $this-&gt;form_validation-&gt;set_rules('sender', 'sender', 'required');
        $this-&gt;form_validation-&gt;set_rules('subject', 'subject', 'required');
        $this-&gt;form_validation-&gt;set_rules('date', 'date');

        $this-&gt;form_validation-&gt;set_error_delimiters('&lt;div class="has-error" style="color: #FF0000"&gt;', '&lt;/div&gt;');

        if ($this-&gt;form_validation-&gt;run() == TRUE) {

            //Setting values for table columns
            $data = array(
                'sender' =&gt; $this-&gt;input-&gt;post('sender'),
                'subject' =&gt; $this-&gt;input-&gt;post('subject'),
                'date' =&gt; $this-&gt;input-&gt;post('date'),


            );
            //Transfering data to Model
            $q = $this-&gt;database-&gt;add_report($data);
            $data['query'] = $this-&gt;database-&gt;view_report($sql);

            if ($q) {
                $data['message'] = '&lt;h3&gt; Your report has successfully submitted!&lt;/h3&gt;';
                $data['success'] = '';
                $data['class'] = 'collapse';
                $this-&gt;load-&gt;view('report_view', $data);

            } else {
                $data['message'] = '&lt;h3&gt; Report submission unsuccessful!&lt;/h3&gt;';
                $data['success'] = '';
                $data['class'] = 'collapse';
                $this-&gt;load-&gt;view('report_view', $data);
            }
        }
        else {
            $data['message'] = '';
            $data['success'] = 'none';
            $data['class'] = '';
            $this-&gt;load-&gt;view('report_view', $data);
        }

    }
    else if ($this-&gt;input-&gt;post('del_hidden')) {

        $from = $this-&gt;input-&gt;post('del_sender');
        $subject = $this-&gt;input-&gt;post('del_subject');
        $date = $this-&gt;input-&gt;post('del_date');

        $qry = "DELETE FROM report WHERE sender = '$from'";
        $q = $this-&gt;database-&gt;delete_report($qry);

        $sql = "SELECT * FROM report";
        $data['query'] = $this-&gt;database-&gt;view_report($sql);

        if ($q) {
            $data['message'] = '&lt;h3&gt; "' . $subject . '"message deleted from database!!&lt;/h3&gt;';
            $data['success'] = '';
            $data['class'] = 'collapse';
            $this-&gt;load-&gt;view('report_view', $data);
        }

    } else {
        $data['success'] = 'none';
        $data['class'] = 'collapse';
        $this-&gt;load-&gt;view('report_view', $data);
    }

}`
</code></pre>