插入mysql后如何在模型上立即显示插入的表单数据?

时间:2019-07-11 15:45:49

标签: php mysql ajax codeigniter

我在addjob.php页面上有表格..在提交时,我希望插入所有数据并在同一页面的模式上显示。

我尝试了在数据库中的正常插入,并将控制器重定向到addjob.php。使用此行:

redirect(BASE_URL."/job/addjobpublic/".$responseid); 

但未定义相同的addjob.php显示$responseid。我认为Ajax应该用于插入数据并在模式上显示,但是混淆了如何使用。

 <form id="createjob_form" class="form-horizontal" method="post" enctype="multipart/form-data" autocomplete="off">

    <div class="form-group">
                <label class="col-md-3 control-label" for="Customer">Public User Name<span style="color: #f04040">*</span></label>
                <div class="col-md-8">
                   <input type="text" id="customers_input" name="customers_input" value="" placeholder="" disabled="disabled"class="form-control input-md" >
              </div>
          </div>

    <div class="form-group">
                        <label class="col-md-3 control-label" for="JobNotes">Job Description<span style="color: #f04040">*</span></label>
                        <div class="col-md-8">
                            <textarea id="JobNotes" name="JobNotes" class="form-control input-md" placeholder="Describe this jobs basics"></textarea>
                        </div>
           </div>
         <div class="form-group">
                      <label class="col-md-3 control-label" for="">Files</label>
                        <div class="col-md-8">
                            <input type="file" name="jobcreatefile[]">
                            <div id="jobcreatefileholder">
                            </div>
                        </div>
         </div>

    <div class="form-group">
            <div class="col-md-2 clear" style="float: none; margin: 0px auto;padding-top: 3%">
                <button id="createjobpublic" name="createjobpublic"   class="btn btn-success customerjob" type="submit" >Save And Continue</button>

            </div>
        </div>

 </form>
 if(isset($responseid){   echo $responseid; ?> 

           }?>  here $responseid is undefined.
*****************************************************          
    in Controller function:  
if (isset($_POST['createjobpublic'])) { 
 $responseid = $this->jobmodel->addJobForpublic();   // here data is inserting.

 redirect(BASE_URL."/job/addjobpublic/".$responseid); // here url is redirecting with responseid, but in the addjob page, responseid is undefined.
 }

我需要在同一addjob.php上插入所有数据,以便我可以访问模态数据或使用Ajax进行插入并在模态中显示数据

0 个答案:

没有答案