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

时间:2013-09-26 00:23:20

标签: php mysql

我在update.php中有这个表单html代码。为了更新,需要使用mysql更新脚本链接到另一个页面save_seeker.php,以便执行它。有没有办法在提交表单的同一页面上执行脚本,以便在查询执行后它保留在同一页面上?

  <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 个答案:

答案 0 :(得分:2)

您可以通过将其添加到表单操作中来在同一文件中进行处理。

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

现在通过检查是否在post变量中设置了

来检查提交操作
<?php 
    if ( isset( $_POST['form_submit'] ) ) {
        // Do processing here.
    }
?>

答案 1 :(得分:-1)

您可以使用include('page-with-update.php'),调用更新函数并使用$ _SERVER [“PHP_SELF”]。

我希望有所帮助!!