Re: HTML Get POST forms

From: Date: Tue, 09 Jul 2002 03:13:40 +0000
Subject: Re: HTML Get POST forms
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-106209@lists.php.net to get a copy of this message
On Mon, Jul 08, 2002 at 08:06:27PM -0700, Varsha Agarwal wrote: > > The browser gives me error that undefined index > 'usename'. Can anyone tell me what could be wrong as i > am very new to HTML and PHP. I'll bet this is happening the first time you view the page. That's happening because you haven't submitted those variables from the form yet. Submit the form and they'll be there. To have your script display correctly under both conditions, do a if/empty test on each key before displaying them. if ( !empty($_POST['username']) ) { echo $_POST['username']; } Another approach is to do a test at the top of the script. When it's empty, set the key to a blank string, which will avoid the unset key errors. if ( empty($_POST['username']) ) { $_POST['username'] = ''; } Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#106209) next »