1

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?

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

  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

1 Answers1

0

You're looking to do a redirect which can be done with the PHP header() function. See this answer for more info:

How do I make a redirect in PHP?

tgrobinson
  • 233
  • 3
  • 15