Hi,

Friday, March 19, 2004, 6:01:00 AM, you wrote:
JV> I want to be able to submit the page to another page vs PHP_SELF.  On
JV> that page I want to be able to validate the form, and if it fails,
JV> return the user to the previous page.  Now that's easy, but the catch is
JV> that I want to retain/repopulate their field values.  

JV> I was thinking of forcing a history.back if possible, but would rather
JV> use some server side code.  I tried researching what can be done with
JV> sending headers, but I don't want to use a GET method.  I want to use
JV> POST.

JV> thoughts?

This is one of the things sessions are used for. Store $_POST in a
session variable and set another variable as failed. Then on your
page1.php just check for the failed variable and if it is there
populate the form with the previous details. You can even include an
error message. The flow would be:

page1.php
session_start();
if(isset($_SESSION['status']) and $_SESSION['status'] == 'failed'){
  $extract($_SEESION['post']);
  unset($_SESSION);
  //fill in form values ie <input type="text" name="name" value="<?php
  echo $name?>">
}else{
  //send blank form
}



page2.php
session_start();
//do validation
 if($status == 'failed'){
   $_SESSION['status'] = 'failed';
   $_SESSION['post'] = $_POST;
   //send redirect header
   exit;
 }else{
   //do success stuff
 }
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to