ricerocket Posted February 7, 2008 Share Posted February 7, 2008 I'm working on the a form and form processor, in the form processor I have added this bit of code to make sure the users fill out all forms: //Check for no blank fields if ( $fname == "" OR $lname == "" OR $staddress == "" OR $apt == "" OR $city == "" OR $country == "" OR $state == "" OR $zipcode == "" OR $phone == "" OR $mm == "" OR $dd == "" OR $yyyy == "" OR $sex == "" OR $username == "" OR $password1 == "" OR $password2 == "" OR $squestion == "" OR $sanswer == "" OR $sanswer2 == "" OR $altemail == "" ) { $ermsg = "All fields of the registration must be completed."; } But the problem is that when I test it it keeps saying that I need to fill out all fields when I am filling them all out, I've gone throught the two files over and over again and can't find any problem such as wrong field names, or wrong variable names, etc., is there any way that I can make it so that it outputs the error message along with what fields need to be filled in? Any help is appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/ Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Err where are all these variables coming from? Usually I would expect to see $_POST['variable name here'] , unless you're doing a variable conversion (not included in your example), such as $fname = $_POST['fname']. It's just a stab in the dark (because I don't know if those variables actually exist), but i'd say that one of those variable names is wrong, or nonexistant, hence the comparison failing in your OR statement. I suspect a simpler test would be foreach($_POST as $var){ if(empty($var){ $ermsg = "BLAH"; break; // because we don't care if any others are missing you're already failed. } } Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460650 Share on other sites More sharing options...
ricerocket Posted February 7, 2008 Author Share Posted February 7, 2008 I'm using a conversion. The first file (the form) is set to post to the processor file which is where the field checker is. the processor file(don't know what else to call it) has a ton of these: $fname = $_POST['fname']; I've gone over then time after time as I said above and I can't seem to find anything wrong, I've checked all the variable names, the form field names, etc. etc. and nothing each time I look, everything is just how it's supposed to be. Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460656 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Put this at the top of ALL your php scripting: error_reporting(E_ALL); You should then see any undefined index errors you're getting. (i suspect this is the problem if you say all the fields were filled in) Also, have you checked that the form names match the POST names you're using? Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460661 Share on other sites More sharing options...
ricerocket Posted February 7, 2008 Author Share Posted February 7, 2008 Yep I've checked them all, I don't know why it would be doing this. Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460669 Share on other sites More sharing options...
ricerocket Posted February 7, 2008 Author Share Posted February 7, 2008 ok I pasted that at the top of my php and it was what you said, and it said there was an undefined variable $squestion which is a dropdown on the form page and everything is spelled correctly, when I take it out of the if statment everything works so I don't know why it's not working. Here is the section from the form: <td class="title"><label for="rcmloginuser">Security Question</label></td><td><select name="squestion> <option value="Select a question...">-------- Please Select One --------</option> <option value="Where were you born?">Where were you born?</option> <option value="What is your favorite restaurant?">What is your favorite restaurant?</option> <option value="What's the name of your school?">What's the name of your school?</option> <option value="Who is your favorite singer?">Who is your favorite singer?</option> <option value="What is your favorite town?">What is your favorite town?</option> <option value="What is your favorite song?">What is your favorite song?</option> <option value="What is your favorite food?">What is your favorite food?</option> <option value="What is your favorite film?">What is your favorite film?</option> <option value="What is your favorite book?">What is your favorite book?</option> <option value="Where was your first job?">Where was your first job?</option> <option value="What is your pet's name?">What is your pet's name?</option> <option value="Where did you grow up?">Where did you grow up?</option></select></td></tr><tr> Do you see anything wrong...? I'm not seeing anything... Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460675 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Did you put the error reporting in? Did you try my example code to test instead of your massive OR statement ? Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460676 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 I hope you can see your error... I can... look harder. Clue: your browser may be displaying in quirks mode... Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460678 Share on other sites More sharing options...
ricerocket Posted February 7, 2008 Author Share Posted February 7, 2008 hmmm I really don't see anything, I know that might make me sound stupid but I really don't see anything, can you tell me what it is thats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460682 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Ok i'll show you the line, you spot the error... <td class="title"><label for="rcmloginuser">Security Question</label></td><td><select name="squestion> ... can you see it now? Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460684 Share on other sites More sharing options...
ricerocket Posted February 7, 2008 Author Share Posted February 7, 2008 ahahaha I can't believe I missed that, thanks a million. Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460685 Share on other sites More sharing options...
haku Posted February 7, 2008 Share Posted February 7, 2008 Those missed double quotes will kill a ninja. Quote Link to comment https://forums.phpfreaks.com/topic/89885-solved-need-form-help/#findComment-460737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.