I am making a simple Form the problem i am facing is when i submit the form values still remains in the field. and I want to clear it after SUCCESSFUL submission. Please hel
They remain in the fields because you are explicitly telling PHP to fill the form with the submitted data.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HERE
Just remove this, or if you want a condition to not do so make a if
statement to that echo
or just cleanup the $_POST
fields.
$_POST = array(); // lets pretend nothing was posted
Or, if successful, redirect the user to another page:
header("Location: success.html");
exit; // Location header is set, pointless to send HTML, stop the script
Which by the way is the prefered method. If you keep the user in a page that was reached through a POST
method, if he refreshes the page the form will be submitted again.