Re: Using PHP Variables with a Header

From: Date: Thu, 12 Jul 2001 12:17:43 +0000
Subject: Re: Using PHP Variables with a Header
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57574@lists.php.net to get a copy of this message
Hey, A simple example with one field: <? if (isset($submit)) { // do fields checking here... if (empty($fname)) { $errmsg = "Name not entered please fill it in!"; } else { // proceed here.... } } ?> <html> <body> <form> <? if (isset($errmsg)) { ?> <font color="red"><?=$errmsg?></font> <? } ?> *Name: <input type="text" name="fname" value="<?=isset($fname) ? $fname : ""?>"> <br> <input type="submit" name="submit"> </form> </body> </html> //Elias "Michael Conley" <mconley@RentHistory.com> wrote in message news:DFA3DA48B1A8B14DBB316506ED07012901C5E5@CRITIC.renthistory.com... > I have a form that requires a user to enter various information (name, > address, phone number, etc...). When they submit this form, the next PHP > page checks to make sure that the required fields were filled in. What I > would like to do is check to see if the required fields are all filled in > and if they are not, save the values they submitted and go back to the > original page, display a message that says the fields that need to be filled > in and populate the rest of the fields with the information the user > orignally submitted. This will keep them from having to type in all of the > information again. > > I can run the checks just fine to see if the required fields are all filled > in. I then save the data from all the fields into variables. What I would > like to do is automatically forward the user back to the original page with > the values (i already have all of the fields set with > "value="$variablename"" to allow them to get the data that is sent back). > The only way I have been able to get this to work is to set this up as a > regular form with hidden HTML fields and a Submit button. I really want > this to be an automatic process. Any thoughts on how to accomplish this? > When I set up a "Header", the user is forwarded back to the page that I > want, but none of the variables go with them (they are set by simply putting > something like "$savedlastname = $lastname, where $lastname is the HTML > variable from the original form). > > Any help is appreciated.

« previous php.general (#57574) next »