You are here: Re: dealing with incorrect input and moving back a page... « All PHP « IT news, forums, messages
Re: dealing with incorrect input and moving back a page...

Posted by juglesh on 09/28/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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация