How can you configure a submit button to redirect to another page while still executing the PHP code?
To configure a submit button to redirect to another page while still executing the PHP code, you can use the header() function in PHP to redirect to the desired page after processing the form data. You can achieve this by checking if the form has been submitted, processing the form data, and then redirecting to the new page using header().
<?php
if(isset($_POST['submit'])){
// Process form data here
// Redirect to another page
header("Location: new_page.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Redirecting Submit Button</title>
</head>
<body>
<form method="post">
<!-- Your form fields here -->
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>