|
Posted by juglesh on 10/13/58 11:29
Domestos wrote:
> Say a user inputs an invalid string into a field - say for example e-mail in
> a form on Page A...
>
> Validation is done on Page B. It notices that the e-mail is incorrect and
> informs the user and jumps them back to the form on Page A.
>
> To get the values the user had input in the e-mail and other fields on the
> form to re-display rather than a blank form I do the following...
>
> On Page B I set $_SESSION('back')=1 and set other variables like
> $_SESSION('name')=$name and $_SESSION('email')=$email
>
> on returning to PageA I check if $_SESSION('back') exists and if so set the
> $name and $email to the $_SESSION superglobals, if not I read the
> information in from a database. I then un-register $_SESSION('back') and the
> others...
well, the easiest way, is on page b, just go 'hey that's an invalid
email addy, use yer back button and fix it' The values that they typed
should be there.
Or, you could have the page A submit to itself.
if ($_POST['submit'] == 'submit'){
//do your validation
}
if (($validation == 'error')OR($_POST['submit'] != 'submit'){
//display the form
// <input type='text' name='email' value='<?php echo $_POST['email']
?>'>
}
else{
// do whatever, validation is passed
}
--
juglesh
Navigation:
[Reply to this message]
|