Re: [PHP] checking for null form fields fails
On Wed, Aug 08, 2001 at 09:14:56AM -0700, Bjorn Van Simaeys wrote: Hey Renze, Don't you think that checking too much is useless and takes a bite out of your performance too? Don't waste your time. Greetz, Bjorn Van Simaeys www.bvsenterprises.com That's right... Checking _too_much_ is useless. But you let me how you check too much? Checking whether or not a variable is set doesn't take any performance. Getting errors and warnings... that sucks. Some guy worked at this company who -we found out- hardly ever checked the results of his db-calls... just because that wouldn't look nice in his code. I mean... what kind of a person are you then. You won't believe how many errors and warnings his code produces. If you use functions calls and don't check the returnvalue(s) your just asking for trouble. And come on... tell me how much performance it takes to see whether or not the returnvalue is true or false after a db-function that takes up about 5 or 6 seconds. Then you're gonna complain about the performance you lose by checking if that db-function succeeded? Tell me... you have any warnings and/or errors logged to your logfiles? Or do you have the errorreportinglevel set to absolute nothing? You ever check if anything goes wrong? How the h*ll can you guarantee functionality of your site? -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
On Tue, Aug 07, 2001 at 11:58:51AM -0600, mike cullerton wrote: i don't use echo either. i use printf. i was just trying to pass along some things i learned reading the manual that were related to the topic. Cool... finaly. You won't believe how many people use echo(). And I realy don't know why. But, hey, if we take a look at many of the (pieces of) scripts you see passing by on this list people don't seem to care about error-checking. Many of 'm don't even look at the logfiles or don't have anything logged into them. And ofcourse I have to admit what's so interesting about error-checking printf? Well... I say, you always have to check anything that returns a value. You can better check to much than not enough. You agree? But you'll have to admit, using braces makes things a lot easier. i already did. H... yeah... Oops... Sorry! Think my error-checking failed :) And because what this was all about was JavaScript (and not PHP), I must admit... it's a bit strange on a PHP-list but hey, the real problem he had was in the JS, so... cool, i came in late in the thread. i _do_ use braces. i like braces. braces are my friends. Most excellent, dude! :) And e, who said anything about returning multiple values? again, just something learned from the manual. Ah... okay... Can be useful... But isn't that more of... you know... like RTFM?!?! But, hey; it's true alright. Do it all the time. Well... pretty often anyway. i was only trying to pass on info about differences between function calls, statements and constructs, and hopefully helping someone out in the process. Okay... problem solved. isn't that what we do here? Sure is!!! CYa'round -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
On Tue, Aug 07, 2001 at 09:26:48AM -0700, Mark Maggelet wrote: This isn't right, empty() won't give an error if $input isn't set. That's true. Empty() doesn't return an error when $input isn't defined. I didn't RT(F)M on this one. I always use (!isset($something) empty($something)) to check whether or not $something is empty/not set. It's realy more of a feeling. Empty() actualy only checks for a value in $something. It's basicaly the same as (!$something) except that empty() doesn't return a warning if $something isn't set (...look, this time I did RTM :). So... basicaly, with empty() you don't check if $something is set. You just don't get to know it. So that's why I use isset() with it. I know the result is the same, but hey... I'm the same guy that checks the returnvalue of printf() and stuff (another thread in this list). So... well... Let's just say I have a 'checking-fetish' of some kind :p -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
On Wed, Aug 08, 2001 at 10:06:51AM +0200, Renze Munnik wrote: (...) checks the returnvalue of printf() and stuff (another thread in this list). oops... it's the same thread... I NEED COFEE!!! -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
Hey Renze, Don't you think that checking too much is useless and takes a bite out of your performance too? Don't waste your time. Greetz, Bjorn Van Simaeys www.bvsenterprises.com --- Renze Munnik [EMAIL PROTECTED] wrote: On Tue, Aug 07, 2001 at 09:26:48AM -0700, Mark Maggelet wrote: This isn't right, empty() won't give an error if $input isn't set. That's true. Empty() doesn't return an error when $input isn't defined. I didn't RT(F)M on this one. I always use (!isset($something) empty($something)) to check whether or not $something is empty/not set. It's realy more of a feeling. Empty() actualy only checks for a value in $something. It's basicaly the same as (!$something) except that empty() doesn't return a warning if $something isn't set (...look, this time I did RTM :). So... basicaly, with empty() you don't check if $something is set. You just don't get to know it. So that's why I use isset() with it. I know the result is the same, but hey... I'm the same guy that checks the returnvalue of printf() and stuff (another thread in this list). So... well... Let's just say I have a 'checking-fetish' of some kind :p -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
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. -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
On Tue, Aug 07, 2001 at 09:23:02AM -0600, mike cullerton wrote: on 8/7/01 2:43 AM, Renze Munnik at [EMAIL PROTECTED] wrote: 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. a couple things. although i agree with the general notion of using braces, return is not a function (the manual calls it a statement), and atleast from what i can find in the manual it doesn't take braces. http://www.php.net/manual/en/functions.returning-values.php also from that page - You can't return multiple values from a function, but similar results can be obtained by returning a list. i'm not really sure what the difference is between function, statement and language construct (which is what echo is). syntactically, i know that functions require parentheses. with echo, the manual says you _cannot_ use parantheses if you are echoing more than one thing. http://www.php.net/manual/en/function.echo.php -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] You're right, return is a statement. I never said, though, to use braces with echo. Actualy I didn't say anything about echo. I never use echo, for some weird reason I just don't like it. I prefer print. So... I don't realy care how echo should be used. But you'll have to admit, using braces makes things a lot easier. And because what this was all about was JavaScript (and not PHP), using braces is a smart thing, because in JavaScript you can make realy ugly constructions in which things _can_ go wrong (no syntax error, but _wrong_) if you don't use braces. In JavaScript it's not required to end each line with a semicolon like in PHP. This can cause weird flows if you also don't use braces. And e, who said anything about returning multiple values? To be honest... I don't understand what you try to achieve with your post Please let me know... -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- 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 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
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. This isn't right, empty() won't give an error if $input isn't set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
on 8/7/01 9:40 AM, Renze Munnik at [EMAIL PROTECTED] wrote: a couple things. although i agree with the general notion of using braces, return is not a function (the manual calls it a statement), and atleast from what i can find in the manual it doesn't take braces. http://www.php.net/manual/en/functions.returning-values.php also from that page - You can't return multiple values from a function, but similar results can be obtained by returning a list. i'm not really sure what the difference is between function, statement and language construct (which is what echo is). syntactically, i know that functions require parentheses. with echo, the manual says you _cannot_ use parantheses if you are echoing more than one thing. http://www.php.net/manual/en/function.echo.php -- mike cullerton You're right, return is a statement. I never said, though, to use braces with echo. Actualy I didn't say anything about echo. I never use echo, for some weird reason I just don't like it. I prefer print. So... I don't realy care how echo should be used. i don't use echo either. i use printf. i was just trying to pass along some things i learned reading the manual that were related to the topic. But you'll have to admit, using braces makes things a lot easier. i already did. And because what this was all about was JavaScript (and not PHP), using braces is a smart thing, because in JavaScript you can make realy ugly constructions in which things _can_ go wrong (no syntax error, but _wrong_) if you don't use braces. In JavaScript it's not required to end each line with a semicolon like in PHP. This can cause weird flows if you also don't use braces. cool, i came in late in the thread. i _do_ use braces. i like braces. braces are my friends. And e, who said anything about returning multiple values? again, just something learned from the manual. To be honest... I don't understand what you try to achieve with your post Please let me know... i was only trying to pass on info about differences between function calls, statements and constructs, and hopefully helping someone out in the process. isn't that what we do here? :) mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] checking for null form fields fails
For all of my HTML forms, I put in some JavaScript to check and make sure no fields are left blank. When the forms are processed in PHP, I also perform a check to make sure the forms fields aren't null (redundant, I know). Anyway, on a form I just made, both JavaScript and PHP think the form has been completed, even when the fields haven't been touched. The code basically looks like this: head script language=JavaScript !-- function VerifyInput () { if (document.myForm.input.value == ) { alert (form not complete); return false; } else { return true; } } // -- /script /head form name=myForm action=myscript.php method=post onSubmit=return VerifyInput() input type=text name=input value= size=30 input type=submit value=submit /form Now, the file myscript.php will have something like this: ?php if (!isset ($HTTP_POST_VARS['input'])) { die (form not complete. cannot continue.); } In all the previous forms I've made, this will catch all uncompleted form fields. However, I made another form in the exact same way, and now both the JavaScript and the PHP checks are failing, i.e. they think something has been entered, when the field has been left blank. In the example above, if the page loaded, then I just pressed the submit button (without even touching the text box), the neither the javascript nor PHP would catch the blank field. Any ideas? Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
On Mon, 6 Aug 2001 13:56:45 -0500, garman ([EMAIL PROTECTED]) wrote: For all of my HTML forms, I put in some JavaScript to check and make sure no fields are left blank. When the forms are processed in PHP, I also perform a check to make sure the forms fields aren't null (redundant, I know). Anyway, on a form I just made, both JavaScript and PHP think the form has been completed, even when the fields haven't been touched. The code basically looks like this: head script language=JavaScript !-- function VerifyInput () { if (document.myForm.input.value == ) { alert (form not complete); return false; } else { return true; } } // -- /script /head form name=myForm action=myscript.php method=post onSubmit=return VerifyInput() 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. input type=text name=input value= size=30 input type=submit value=submit /form Now, the file myscript.php will have something like this: ?php if (!isset ($HTTP_POST_VARS['input'])) { die (form not complete. cannot continue.); } well, if it makes it this far, $input will be set, but the value will be . try empty() instead of !isset() - Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]