Jump to content

[SOLVED] Need form help


ricerocket

Recommended Posts

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...

Link to comment
Share on other sites

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.
  }
}

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.