How to put the form data when i press back button?

Hi all,
I have an registration form.
I validate the data submitted by the user… but if any wrong or mis-match data is found it shows the message to give correct data…
Now when i goes back, that user entered data is not there in the form fields, user need to enter again…
I want to put the data in their fields and allow the user to correct the respective field…

Give me help regarding this…

Thanking you…

give me an example to do it.

You can:

  1. make the form call its own script instead of another script, that way you can use the post (or get) values to repopulate the form
  2. put the form values in a session, and then use those session values to repopulate the form


Here’s the Session variant:

Your HTML form:

<input type="text" name="sometextfield" value="<?php echo !empty($_SESSION['sometextfield'] ? htmlentities($_SESSION['sometextfield']) : '' ; ?>" />

Your PHP processor:

if(!empty($_POST['sometextfield'])) {
    $_SESSION['sometextfield'] = $_POST['sometextfield'];

And here’s the post to self variant:

Your html form:

if(empty($_POST['sometextfield'])) {
    echo "<h1>You made an error in this here field, sonny Jim!</h1>";
<input type="text" name="sometextfield" value="<?php echo !empty($_POST['sometextfield'] ? htmlentities($_POST['sometextfield']) : '' ; ?>" />