2016-09-16 138 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 = “你的重定向链接”