Re: [PHP] Form Validation Issues
On Tue, May 29, 2007 12:05 am, Greg Donald wrote: On 5/24/07, Robert Cummings [EMAIL PROTECTED] wrote: *lol* You must have missed the other thread... hence the wink on the end :) I'm guessing not everyone uses a threaded email client. And some people always feel the need to post their 'thoughts' no matter how well the question has already been beaten to death. :) Speaking of which... :-) Suppose, just for the sake of argument, that Puerto Rico becomes the 51st state? Your code is now broken Perhaps it would be wiser to web-scrape an ISO standard listing of states every six months or so, and popuplate your state listings in the DB from that. That's what I do with the country list, actually, as I can't even name half the countries, much less spell them nor get the right 2-char code... :-) If anything goes wrong, you can point to ISO as the culprit too! :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On 5/24/07, Robert Cummings [EMAIL PROTECTED] wrote: *lol* You must have missed the other thread... hence the wink on the end :) I'm guessing not everyone uses a threaded email client. And some people always feel the need to post their 'thoughts' no matter how well the question has already been beaten to death. :) -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
tedd wrote: SNIP on topic stuff Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown Hi Jim: You might try the array below and the quote above, I believe, was Douglas MacArthur of WWII fame. Is that the same Douglas MacArthur who was once known as William Shakespeare :-) IIRC that is from Twelfth Night. Cheers -- David Robley No, I'm from Iowa. I only work in Outer Space. Today is Sweetmorn, the 73rd day of Discord in the YOLD 3173. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
tedd wrote: SNIP on topic stuff Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown Hi Jim: You might try the array below and the quote above, I believe, was Douglas MacArthur of WWII fame. Is that the same Douglas MacArthur who was once known as William Shakespeare :-) IIRC that is from Twelfth Night. Cheers -- David Robley I guess that MacArthur re-quoted it in one of his speeches, because I recall a WWII newsreel where he said it. But in any event, the author of the quote isn't Unknown. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
tedd wrote: tedd wrote: SNIP on topic stuff Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown Hi Jim: You might try the array below and the quote above, I believe, was Douglas MacArthur of WWII fame. Is that the same Douglas MacArthur who was once known as William Shakespeare :-) IIRC that is from Twelfth Night. Cheers -- David Robley I guess that MacArthur re-quoted it in one of his speeches, because I recall a WWII newsreel where he said it. But in any event, the author of the quote isn't Unknown. Cheers, tedd well, it was to me. And the digging on google that I did, didn't return anything pointing to either. But, I was told that it was a quote from MacArthur and from Shakespeare. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
At 8:57 AM -0700 5/23/07, Jim Lucas wrote: kvigor wrote: if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != -snip- Ok, here is something that might help you. $states['AL'] = 'Alabama'; $states['AK'] = 'Alaska'; -snip- $states['WY'] = 'Wyoming'; now use this like this if ( !isset($states[$value]) !in_array($value, $states) ) { // do something because I can't find the state } use something like this so your logical errors will be reduced -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown Hi Jim: You might try the array below and the quote above, I believe, was Douglas MacArthur of WWII fame. Cheers, tedd $states = array( 'AL' = 'Alabama', 'AK' = 'Alaska', 'AS' = 'American Samoa', 'AZ' = 'Arizona', 'AR' = 'Arkansas', 'CA' = 'California', 'CO' = 'Colorado', 'CT' = 'Connecticut', 'DE' = 'Delaware', 'DC' = 'District Of Columbia', 'FM' = 'Federated States Of Micronesia', 'FL' = 'Florida', 'GA' = 'Georgia', 'GU' = 'Guam', 'HI' = 'Hawaii', 'ID' = 'Idaho', 'IL' = 'Illinois', 'IN' = 'Indiana', 'IA' = 'Iowa', 'KS' = 'Kansas', 'KY' = 'Kentucky', 'LA' = 'Louisiana', 'ME' = 'Maine', 'MH' = 'Marshall Islands', 'MD' = 'Maryland', 'MA' = 'Massachusetts', 'MI' = 'Michigan', 'MN' = 'Minnesota', 'MS' = 'Mississippi', 'MO' = 'Missouri', 'MT' = 'Montana', 'NE' = 'Nebraska', 'NV' = 'Nevada', 'NH' = 'New Hampshire', 'NJ' = 'New Jersey', 'NM' = 'New Mexico', 'NY' = 'New York', 'NC' = 'North Carolina', 'ND' = 'North Dakota', 'MP' = 'Northern Mariana Islands', 'OH' = 'Ohio', 'OK' = 'Oklahoma', 'OR' = 'Oregon', 'PW' = 'Palau', 'PA' = 'Pennsylvania', 'PR' = 'Puerto Rico', 'RI' = 'Rhode Island', 'SC' = 'South Carolina', 'SD' = 'South Dakota', 'TN' = 'Tennessee', 'TX' = 'Texas', 'UT' = 'Utah', 'VT' = 'Vermont', 'VI' = 'Virgin Islands', 'VA' = 'Virginia', 'WA' = 'Washington', 'WV' = 'West Virginia', 'WI' = 'Wisconsin', 'WY' = 'Wyoming' ); -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Wed, May 23, 2007 7:41 am, kvigor wrote: if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || This mess will *ALWAYS* evaluate to TRUE, because the $value is ALWAYS only one value, and thus the other 99 values are going to evaluate to TRUE and you have || between them... So you have: TRUE || TRUE || TRUE || FALSE || TRUE || TRUE ... || TRUE which is always gonna boil down to TRUE. You wanted instead of || Actually, it would be MUCH better imho to set up a couple arrays like: $states = array('Alabama', 'Alaska', ...); $sts = array('AL', 'AK', ...); if (!isset($states[$value]) !isset($sts[$value])){ echo Bad Dog!; } YMMV -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Wed, May 23, 2007 10:48 am, Robert Cummings wrote: On Wed, 2007-05-23 at 10:10 -0500, Greg Donald wrote: On 5/23/07, kvigor [EMAIL PROTECTED] wrote: [-- SNIPPITY SNIP SNIP --] != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these You should really look into learning in_array() for stuff like this. Wouldn't that slow things down and increase the memory footprint? ;) Not in any meaningful way. And a huge gain in maintainability/readability for a meaningless loss in performance is a win -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Thu, 2007-05-24 at 17:58 -0500, Richard Lynch wrote: On Wed, May 23, 2007 10:48 am, Robert Cummings wrote: On Wed, 2007-05-23 at 10:10 -0500, Greg Donald wrote: On 5/23/07, kvigor [EMAIL PROTECTED] wrote: [-- SNIPPITY SNIP SNIP --] != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these You should really look into learning in_array() for stuff like this. Wouldn't that slow things down and increase the memory footprint? ;) Not in any meaningful way. And a huge gain in maintainability/readability for a meaningless loss in performance is a win *lol* You must have missed the other thread... hence the wink on the end :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Wed, 2007-05-23 at 07:41 -0500, kvigor wrote: if($field == conState || $field == schState || $field == strState) //if these 3 fields are entered { if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' || $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these I'm going to vomit after seeing your if statement's condition. Anyways, you want between all those and NOT ||. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
2007. 05. 23, szerda keltezéssel 07.41-kor kvigor ezt írta: Hi, I have an issue with a particular if statement when I check 3 form fields for their value. The problem is no matter what input is entered in the fields the output is the same. I only added the 3 fields in question of the form to reduce heartache for the readers of this post. Output always reads: Please correct the following State fields. Example: Enter state as Illinois or IL not ILLINOIS. Consumer State School State Store State The code is: ?php $label_array = array (conName = Consumer Name, conAddress = Consumer Address, conCity = Consumer City, conState = Consumer State, conZip = Consumer Zip Code, conPhone = Consumer Phone, schName = School Name, schAddress = School Address, schCity = School City, schState = School State, schZip = School Zip Code, strName = Store Name, strCity = Store City, strState = Store State); //check data fields for correct data foreach($_POST as $field = $value) { if($field == conState || $field == schState || $field == strState) //if these 3 fields are entered { if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' || $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these you should replace all those || -s above with -s since you want to be sure it does not match any of the states greets Zoltán Németh { $state[$field] = badstate; //then } }//end check } if(@sizeof($state) 0) //check size of array and display error message { echo div class='ermess1'br /Please correct the following \State\ fields.nbsp;nbsp;Example: Enter state as Illinois or IL not ILLINOIS./div; foreach($state as $field = $value) // display the fields where input is incorrect { echo nbsp;nbsp;div{$label_array[$field]}/div; } } echo link href='css/SOS.css' rel='stylesheet' type='text/css' / form id='process' method='post' action='form.php' label for='conState' class='stateLabel' *State:/label input name='conState' type='text' class='state' id='textfield' value='{$_POST['conState']}' / label for='schState' class='stateLabel'*State:/label input name='schState' type='text' class='state' id='textfield' value='{$_POST['schState']}'/ label for='strStat' class='stateLabel'*State:/label input name='strState' type='text' class='state' id='textfield' value='{$_POST['strState']}' / br / br / br / label for='Reset'/label input type='reset' name='reset' value='Reset' id='Submit'/ label for='Sumbit'/label input type='submit' name='submit' value='Submit' id='Reset'/ /form; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On 5/23/07, kvigor [EMAIL PROTECTED] wrote: The code is: ?php $label_array = array (conName = Consumer Name, conAddress = Consumer Address, conCity = Consumer City, conState = Consumer State, conZip = Consumer Zip Code, conPhone = Consumer Phone, schName = School Name, schAddress = School Address, schCity = School City, schState = School State, schZip = School Zip Code, strName = Store Name, strCity = Store City, strState = Store State); //check data fields for correct data foreach($_POST as $field = $value) { if($field == conState || $field == schState || $field == strState) //if these 3 fields are entered { if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' || $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these You should really look into learning in_array() for stuff like this. Your logic seems weird to me, using != with a bunch of ||'s, is it possible you need to those together? { $state[$field] = badstate; //then } }//end check } if(@sizeof($state) 0) //check size of array and display error message I can't think of a good reason to suppress an error coming from sizeof(). It will return zero for anything that is unset. You might switch to count(), it's one character less to type than sizeof() and much more common in other programming languages. echo div class='ermess1'br /Please correct the following \State\ fields.nbsp;nbsp;Example: Enter state as Illinois or IL not ILLINOIS./div; foreach($state as $field = $value) // display the fields where input is incorrect { echo nbsp;nbsp;div{$label_array[$field]}/div; } } echo link href='css/SOS.css' rel='stylesheet' type='text/css' / form id='process' method='post' action='form.php' label for='conState' class='stateLabel' *State:/label input name='conState' type='text' class='state' id='textfield' value='{$_POST['conState']}' / label for='schState' class='stateLabel'*State:/label input name='schState' type='text' class='state' id='textfield' value='{$_POST['schState']}'/ label for='strStat' class='stateLabel'*State:/label input name='strState' type='text' class='state' id='textfield' value='{$_POST['strState']}' / br / br / br / label for='Reset'/label input type='reset' name='reset' value='Reset' id='Submit'/ label for='Sumbit'/label input type='submit' name='submit' value='Submit' id='Reset'/ /form; ? Looks like you just need to do some logic debugging to get things wired up how you want. Try adding this to the top of your script so the post action shows you more info: if( isset( $_POST['submit'] ) ) { echo 'pre'; print_r( $_POST ); echo '/pre'; } -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
Thanks Dan, Work like a dream. I solute you. Daniel Brown [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 5/23/07, kvigor [EMAIL PROTECTED] wrote: Hi, I have an issue with a particular if statement when I check 3 form fields for their value. The problem is no matter what input is entered in the fields the output is the same. I only added the 3 fields in question of the form to reduce heartache for the readers of this post. Output always reads: Please correct the following State fields. Example: Enter state as Illinois or IL not ILLINOIS. Consumer State School State Store State The code is: ?php $label_array = array (conName = Consumer Name, conAddress = Consumer Address, conCity = Consumer City, conState = Consumer State, conZip = Consumer Zip Code, conPhone = Consumer Phone, schName = School Name, schAddress = School Address, schCity = School City, schState = School State, schZip = School Zip Code, strName = Store Name, strCity = Store City, strState = Store State); //check data fields for correct data foreach($_POST as $field = $value) { if($field == conState || $field == schState || $field == strState) //if these 3 fields are entered { if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' || $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these { $state[$field] = badstate; //then } }//end check } if(@sizeof($state) 0) //check size of array and display error message { echo div class='ermess1'br /Please correct the following \State\ fields.nbsp;nbsp;Example: Enter state as Illinois or IL not ILLINOIS./div; foreach($state as $field = $value) // display the fields where input is incorrect { echo nbsp;nbsp;div{$label_array[$field]}/div; } } echo link href='css/SOS.css' rel='stylesheet' type='text/css' / form id='process' method='post' action='form.php' label for='conState' class='stateLabel' *State:/label input name='conState' type='text' class='state' id='textfield' value='{$_POST['conState']}' / label for='schState' class='stateLabel'*State:/label input name='schState' type='text' class='state' id='textfield' value='{$_POST['schState']}'/ label for='strStat' class='stateLabel'*State:/label input name='strState' type='text' class='state' id='textfield' value='{$_POST['strState']}' / br / br / br / label for='Reset'/label input type='reset' name='reset' value='Reset' id='Submit'/ label for='Sumbit'/label input type='submit' name='submit' value='Submit' id='Reset'/ /form; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You're doing all OR statements. This means if it's not this or it's not this or it's not this or it's not this Replace
Re: [PHP] Form Validation Issues
On Wed, 2007-05-23 at 10:17 -0500, kvigor wrote: Thanks Dan, Work like a dream. I solute you. Don't look now Dan... but you're dissolving!!! *hehe* Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Wed, 2007-05-23 at 10:10 -0500, Greg Donald wrote: On 5/23/07, kvigor [EMAIL PROTECTED] wrote: [-- SNIPPITY SNIP SNIP --] != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these You should really look into learning in_array() for stuff like this. Wouldn't that slow things down and increase the memory footprint? ;) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote: You should really look into learning in_array() for stuff like this. Wouldn't that slow things down and increase the memory footprint? ;) It'd be interesting to see a benchmark. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
kvigor wrote: if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 'FL' || $value != 'Georgia' || $value!= 'GA' || $value != 'Hawaii' || $value!= 'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 'Illinois' || $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 'Wyoming' || $value!= 'WY') //if they don't the match these Ok, here is something that might help you. $states['AL'] = 'Alabama'; $states['AK'] = 'Alaska'; $states['AZ'] = 'Arizona'; $states['AR'] = 'Arkansas'; $states['CA'] = 'California'; $states['CO'] = 'Colorado'; $states['CT'] = 'Conneticut'; $states['DE'] = 'Delaware'; $states['FL'] = 'Florida'; $states['GA'] = 'Georgia'; $states['HI'] = 'Hawaii'; $states['ID'] = 'Idaho'; $states['IL'] = 'Illinois'; $states['IN'] = 'Inidiana'; $states['IA'] = 'Iowa'; $states['KS'] = 'Kansas'; $states['KY'] = 'Kentucky'; $states['LA'] = 'Louisiana'; $states['ME'] = 'Maine'; $states['MD'] = 'Maryland'; $states['MA'] = 'Massachusetts'; $states['MI'] = 'Michigan'; $states['MN'] = 'Minnesota'; $states['MS'] = 'Mississippi'; $states['MO'] = 'Missouri'; $states['MT'] = 'Montana'; $states['NE'] = 'Nebraska'; $states['NV'] = 'Nevada'; $states['NH'] = 'New Hampshire'; $states['NJ'] = 'New Jersey'; $states['NM'] = 'New Mexico'; $states['NY'] = 'New York'; $states['NC'] = 'North Carolina'; $states['ND'] = 'North Dakota'; $states['OH'] = 'Ohio'; $states['OK'] = 'Oklahoma'; $states['OR'] = 'Oregon'; $states['PA'] = 'Pennsylvania'; $states['RI'] = 'Rhode Island'; $states['SC'] = 'South Carolina'; $states['SD'] = 'South Dakota'; $states['TN'] = 'Tennesee'; $states['TX'] = 'Texas'; $states['UT'] = 'Utah'; $states['VT'] = 'Vermont'; $states['VA'] = 'Virginia'; $states['WA'] = 'Washington'; $states['WV'] = 'West Virginia'; $states['WI'] = 'Wisconsin'; $states['WY'] = 'Wyoming'; now use this like this if ( !isset($states[$value]) !in_array($value, $states) ) { // do something because I can't find the state } use something like this so your logical errors will be reduced -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On Wed, 2007-05-23 at 10:55 -0500, Greg Donald wrote: On 5/23/07, Robert Cummings [EMAIL PROTECTED] wrote: You should really look into learning in_array() for stuff like this. Wouldn't that slow things down and increase the memory footprint? ;) It'd be interesting to see a benchmark. You're good at those... but I'll pull off the top of my head that the array overhead ought to require more memory due to the need for indexes (maybe) but at least for internal tree structure. The speed ought to slow down since the array will need to be created and built. Then using in_array() I'm guessing is a linear search since values aren't sorted (at least I can't image the values being sorted). You could probably overcome the speed issue using an array with the values as indexes instead of the values and using isset() to check for membership of the value :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote: $states['TN'] = 'Tennesee'; :%s/Tennesee/Tennessee/ -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote: Ok, here is something that might help you. $states['AL'] = 'Alabama'; $states['AK'] = 'Alaska'; And a little something for you as well: :%s/=/=/g -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
Greg Donald wrote: On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote: Ok, here is something that might help you. $states['AL'] = 'Alabama'; $states['AK'] = 'Alaska'; And a little something for you as well: :%s/=/=/g oops, did over look that one -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Validation Issues
Greg Donald wrote: On 5/23/07, Jim Lucas [EMAIL PROTECTED] wrote: $states['TN'] = 'Tennesee'; :%s/Tennesee/Tennessee/ Not my typo, this was the ops list just reformatted. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php