Re: checking for null form fields fails

From: Date: Tue, 07 Aug 2001 08:43:09 +0000
Subject: Re: checking for null form fields fails
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-61565@lists.php.net to get a copy of this message
On Mon, Aug 06, 2001 at 12:31:38PM -0700, Mark Maggelet wrote: > i can't tell if it's just a email formatting thing, but if there's a > line break in the onsubmit string it might mess things up. It no _might_ mess things up... It sure does! Good one. But... another thing. You just might want to consider using braces. They're not invented for nothing. When you call functions (like return) you should use braces. Especialy when you start writing more complex scripts, the not using any braces, is just the thing that may because a lot of trouble. Weird thing btw, that the JavaScript console doesn't show any errors when there's a newline between return and verifyInput. I mean... it's a good example of a syntax error. But that stupid console doesn't show any damn thing. Btw... not that it matter anyway, but: onsubmit="return <\n> verifyInput();" doesn't do the right thing (as we've all seen), but: onsubmit="return( <\n> verifyInput());" does. (...) > well, if it makes it this far, $input will be set, but the value will > be "". try empty() instead of !isset() Well, Mark... almost! You shouldn't use empty() _instead_ of isset(). You should use 'm together: if (isset ($input) && !empty($input)) { print ("Okay... form is completed!"); } else { print ("No way... can't do!"); } Because, when you check using empty($input) there's still the possibility that $input isn't defined at all. And then some horrible error still arises in your logfile. Note btw that you shouldn't change the order of isset() and empty() in the above example. -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- H: +31 23 5516190 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#61565) next »