doujiang6944
2013-09-26 00:23
浏览 22
已采纳

在同一页面中查询执行php脚本

I have this form html code in update.php. For updating, it's required to link to another page save_seeker.php with mysql update script for it to be executed. Is there any way to execute the script in same page on submitting form so that after query execution it remains on same page?

  <form action= "save_seeker.php" method = "post">
  Update details !<br><br>
  First Name
  <input type = "text" name = "fname" value = "<?php echo $disp['fname'];?>"><br><br> 
  Last Name 
  <input type = "text" name = "lname" value = "<?php echo $disp['lname'];?>"><br><br>
  Contact number
  <input type = "text" name = "contact" value = "<?php echo $disp['contact'];?>"><br><br>
  Email-id
  <input type = "email" name = "email" value = "<?php echo $disp['email'];?>"><br><br>
  Address
  <input type = "text" name = "address" value = "<?php echo $disp['address'];?>"><br><br> 
  Experience
  <input type = "number" name = "experience" value = "<?php echo $disp['experience'];?> "><br><br> 
  Qualification
  <input type = "text" name = "qualification" value = "<?php echo $disp['qualification'];?>"><br><br>
  <input type = "Submit" value = "Update">
  </form>   
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dstk51319 2013-09-26 00:27
    已采纳

    You could do the processing in the same file by adding this into the form action.

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
        <!-- Input fields in here-->
        <input type="submit" name="form_submit" value="Submit">
    </form>
    

    Now check for the submit action by checking if it is set in the post variable

    <?php 
        if ( isset( $_POST['form_submit'] ) ) {
            // Do processing here.
        }
    ?>
    
    点赞 打赏 评论
  • dounanyin3179 2013-09-26 00:49

    You could use the include('page-with-update.php') , call the update function and use the $_SERVER["PHP_SELF"].

    I hope helped!!

    点赞 打赏 评论

相关推荐