php - Redirect to a different webpage on an if isset button
Get the solution ↓↓↓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
Answer
Solution:
You're looking to do a redirect which can be done with the PHPheader()
function. See this answer for more info:
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: constant expression contains invalid operations
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.