Jump to content

why does this always throw an error??


markbett

Recommended Posts

this is suppose to be processing a dynamically created form

i check to make sure the form is creating the right values for the text boxes that are being processed

[code]     <table width="60%" border="0" align="center" cellpadding="0">
        <tr>
          <td colspan="2" class="box_title">Guest 1</td>
          </tr>
        <tr>
          <td class="event_text">Name:</td>
          <td><input name="guest_name1" type="text" class="event_desc" id="guest_name1" value="" size="30" maxlength="50"></td>
        </tr>
        <tr>
          <td class="event_text">E-mail Address: </td>
          <td><input name="guest_email1" type="text" class="event_desc" id="guest_email1" size="30"></td>
        </tr>
        <tr>
          <td class="event_text">Confirm Email: </td>
          <td><input name="guest_veri1" type="text" class="event_desc" id="guest_veri1" size="30" maxlength="50"></td>
        </tr>
      </table>[/code]

for some reason it always says there is an error though...

[code]<?
$errors = false;
$i='1';
$guests=mysql_real_escape_string($_POST['guests']);
$guest_array = array();

while($i<=$guests){
if(!$_POST[${guest_name.$i}] ||
  !$_POST[${guest_email.$i}] ||
  !$_POST[${guest_veri.$i}]){
$error .= "Oops.  It looks like something bad happened when you provided us with".
" your guests information.";
$errors = true;

if(!$_POST[${guest_name.$i}]){
$error .= "You forgot to enter in guest $i's name.\n";
}
if(!$_POST[${guest_email.$i}]){
$error .= "You forgot to enter in guest $i's email address.\n";
$email_error = true;
}
if(!$_POST[${guest_veri.$i}]){
$error .= "You forgot to verify guest $i's email address.\n";
$email_error = true;
}
} //closes the checks to see that all fields were filled in
  if($email_error == false){
if($_POST[${guest_email.$i}] !=
  $_POST[${guest_veri.$i}]){
$errors = true;
$error .= "The e-mail addresses do not match!\n";
$email_error = true;
}
  }
//check to make sure the email addresses are valid
if(validate_email($guest_email1)){
$errors = true;
$error .= "The e-mail address for guest $i does not appear to be valid!\n";
$email_error = true;
}
//all error checking is done


//move on to the next guest
$i++;
}
//check to see if an error occured while checking the guests information
if($errors == true){
$error = nl2br($error);
include $_SERVER['DOCUMENT_ROOT'].'/sbqa/html/forms/guests.htm';  //spit them back to the form
  footer();
  exit();
  }[/code]
Link to comment
Share on other sites

got it... for those that endevor down a similar path the code that works is:

while($i<=$guests){
if(!$_POST["{guest_name".$i] ||
  !$_POST["guest_email".$i] ||
  !$_POST["guest_veri".$i]){
$error .= "Oops.  It looks like something bad happened when you provided us with".
" your guests information.".$_POST['${guest_name.$i}\n'];
$errors = true;

if(!$_POST["{guest_name".$i]){
$error .= "You forgot to enter in guest $i's name.\n";
}
if(!$_POST["guest_email".$i]){
$error .= "You forgot to enter in guest $i's email address.\n";
$email_error = true;
}
if(!$_POST["guest_veri".$i]){
$error .= "You forgot to verify guest $i's email address.\n";
$email_error = true;
}
} //closes the checks to see that all fields were filled in
  if($email_error == false){
if($_POST["guest_email".$i] !=
  $_POST["guest_veri".$i]){
$errors = true;
$error .= "The e-mail addresses do not match!\n";
$email_error = true;
}
  }
//check to make sure the email addresses are valid
if(validate_email($_POST["guest_veri".$i])){
$errors = true;
$error .= "The e-mail address for guest $i does not appear to be valid!\n";
$email_error = true;
}
//all error checking is done


//move on to the next guest
$i++;
}
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.