This is my code for my submit button. Once data submitted to mysql i want it to redirect to page.html.
<form name="gender."; action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
I have added
<?php
header("location:page.html");
exit; }
<?
to the very top of my form page. However it just loads page.html rather loading after submit button is clicked.
1) Please don’t use
PHP_SELF, it is vulnerable to exploitation. If you want the action to be the same page, just leave it empty.2) The
header(), which I assume is at the top of the page since it works, has no control on it.EDIT1: Expanding based on question in comment below.
3) The
header()directive will forward the browser to the new page and stop any further processing. Because of this, all the MySQL processing should be complete before redirecting.4) The
$_POSTarray gets the key names from thenameattribute of the inputs, so be sure that your<input type="submit" name="submitbtn" ...matches the$_POST['submitbtn']