简体   繁体   English

在if isset按钮上重定向到其他网页

[英]Redirect to a different webpage on an if isset button

I can easily add an href link in html to redirect to another page, but what is the PHP code for a link to a different page when a button is clicked? 我可以轻松地在html中添加href链接以重定向到另一个页面,但是单击按钮时链接到另一个页面的PHP代码是什么?

page1.php page1.php

<div class="col-md-4 col-md-offset-8">
  <input type="submit" class="btn bg-color-dark-gold color-white form-control" name="submit" value="SAVE">
</div>

page2.php page2.php

  if (isset($_POST['submit']) && $_POST['submit'] == 'SAVE')
  {
    $leaseid = $_GET['i'];
    $lease_name = $_POST['lease_name'];
    $lease_type = $_POST['lease_type'];
    $lease_address = $_POST['lease_address'];
    $lease_price = $_POST['lease_price'];
    $lease_condition = $_POST['lease_condition'];
    $lease_description = $_POST['lease_description'];

    $mcProperty->UpdateLease($db, $leaseid, $lease_type, $lease_name, $lease_address, $lease_price, $lease_condition, $lease_description);
  }

I'd like to add something in page2.php that returns to page1.php on button click and after the update SQL 我想在page2.php中添加一些内容,在单击按钮并在更新SQL之后返回到page1.php。

You're looking to do a redirect which can be done with the PHP header() function. 您正在寻找可以使用PHP header()函数完成的重定向。 See this answer for more info: 查看此答案以获取更多信息:

How do I make a redirect in PHP? 如何在PHP中进行重定向?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM