2016-09-16 132 views
0

在這裏,我增加了一個表格數據模型笨意見頁在表單提交表單後顯示成功彈出?

<a class="handCursor " href="javascript:void(0)" id="franchise">Franchisee </a> 
<!-- Modal --> 
<div class="modal fade" id="franchisee_signup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
     <form action="<?php echo base_url();?>general/general_form" method="POST" name="signup"> 
      <div class="modal-header bg-primary"> 
       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
       <h4 class="modal-title" id="myModalLabel"><i class="fa fa-desktop"></i> Request For Franchisee Program</h4> 
      </div> 
      <div style="clear: both;"></div> 
      <div class="modal-body clearfix"> 
       <div class="bk_lft" style="width:100%;"> 
        <div class="bk_gr" style="width:100% !important"> 
        <div class="contact_form2"> 
         <div class="bk_roominfo"> 
          <div class="clearfix"></div> 
          <div class="frm_clmn"> 
           <label>First Name: <em style="color:#F00;">*</em></label> 
           <input name="first_name" id="txt_name" type="text"> 
           <input name="form_type" id="company_name" type="hidden" value="franchise"> 
          </div> 
          <div class="frm_clmn1"> 
           <label>Last Name: <em style="color:#F00;">*</em></label> 
           <input name="last_name" id="txt_lname" type="text"> 
          </div> 
          <div class="frm_clmn"> 
           <label>Phone: <em style="color:#F00;">*</em></label> 
           <input name="mobile" id="txt_mobile" type="text"> 
          </div> 
          <div class="frm_clmn1"> 
           <label>Email: <em style="color:#F00;">*</em></label> 
           <input name="email" id="txt_email" type="text"> 
          </div> 
          <div class="frm_clmn1" style="width:100%;"> 
           <label>Message:<em style="color:#F00;">*</em></label> 
           <textarea name="message" id="txt_message" cols="" rows="" style="resize:none;"></textarea> 
          </div> 
          <div class="bk_bt" style="float:left; margin-top:12px;"> 
           <button type="submit" name="send_contact_enq" id="send_contact_enq" value="Continue" style="float:left;">Send</button> 
          </div> 
         </div> 
        </div> 
        <div class="clearfix"></div> 
        </div> 
       </div> 
      </div> 
     </form> 
     </div> 
    </div> 
</div> 

這是表格,我們在控制器

public function general_form() 
{ 
    $post = $this->input->post(); 
    unset($post['send_contact_enq']); 
    $insert_id = $this->custom_db->insert_record('corporate_form_reqlist',$post); 
    redirect(base_url()."general/index"); 
} 

提交表單之後添加插入查詢,同時插入db我們重定向到首頁。我們需要在來自控制器的重定向之前有可能在關閉彈出消息重定向發生之後顯示成功彈出窗口。

我們盡了所有的邏輯,我知道,但沒有得到正確的響應

+0

PHP返回true flashdata傳遞data.see .... HTTPS:/ /www.codeigniter.com/user_guide/libraries/sessions.html –

+0

我試過這個也是 $ this-> session-> set_flashdata('success_msg','請求設置爲Admin。Admin儘快找回你'); 但它不會得到 – Vigneshrajkumar

+0

如果你能夠彈出成功的消息,單擊確定或關閉按鈕只需添加此'window.location =「http://www.yoururl.com」;' –

回答

0
if($insert_id=='success'){//change success based on the returned value of the model 
    echo "<script> 
     alert('Success'); 
     window.location.href='".base_url('general/index')."'; 
     </script>"; 
} 
0

嘗試通過一些價值PARAM並通過檢查,在重定向頁面給成功的消息..

redirect(base_url()."general/index?status=success"); 

和一般/索引文件

if(isset($_GET['status']) && $_GET['status'] == "success"){ 
     echo "Successfull Message"; 
} 
0

您可以使用您的形式AJAX功能,將數據發送到PHP不重定向到執行general_form任務。如果成功地插入記錄數據庫,然後使用JavaScript觸發警報()或提示()和windows.location = 「你的重定向鏈接」