Ok, so I used to be very good in HTML, PHP, and JS, but it's been a long time since I used it. been trying to make just a simple order form for a friends business. Though I wanted it to do server side validation and emailing... But it doesn't do anything.... on submit I get no errors when there are and with no errors I get no email to my inbox..

What it is supposed to do is gather what pictures they checked and their sizes as well as a person info and email it to an email address. Though I want it to check for required areas and correct input (like email has @ and a .com in it, zip is digits only, etc... But yeah my code shows the order form and looks nice, but does nothing....

<?php
require_once "formvalidator.php";
  $error_hash = 'no';
  $show_form = true;
class MyValidator extends CustomValidator
{
	function DoValidate(&$formars,&$error_hash)
	{
        if(stristr($formars['comments'],'http://'))
        {
            $error_hash['comments']="No URLs allowed in comments";
            return false;
        }
		return true;
	}
}

  if (isset($_REQUEST['Submit'])) 
{
      $validator = new FormValidator();
      $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
      $validator->addValidation("first", "req", "<B>Please provide your first name for invoice.</B>");
      $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
      $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
      $validator->addValidation("zip", "req", "<B>Please provide your zipcode for invoice.</B>");
      $validator->addValidation("last", "req", "<B>Please provide your last name for invoice.</B>");
      $validator->addValidation("zip", "num", "<B>Numbers only in Zipcode.</B>");
      $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");
      if ($validator->ValidateForm()) {
          $show_form = false;
      } else {
          echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
          $error_hash = $validator->GetErrors();
          foreach ($error_hash as $inpname => $inp_err) {
              echo "<center><p>$inpname : $inp_err</p></center>\n";
              $show_form = true;
          }
      }
          if ($show_form === false){
          // Grab the form vars
	  $Pic = $_REQUEST['pic[]'] ;
	  $Size = $_REQUEST['size[]'] ;
          $Email = $_REQUEST['email'];
          $Name = $_REQUEST['first'. 'last'];
          $Addr = $_REQUEST['addr'];
          $City = $_REQUEST['city'];
          $State = $_REQUEST['state'];
          $Zip = $_REQUEST['zip'];
	  $comments = $_REQUEST['comments'] ;
 
if(empty($pic)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  } 
  else 
  {
    $r = count($pic);
    for($i=0; $i < $r; $i++)
    {
      echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
    }
  }
if(empty($size)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
  } 
  else 
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
    }
  }

        //message body
        $mail_body .= "$Pic"."\r\n";
        $mail_body .= "$Size"."\r\n";
        $mail_body .= "$Email"."\r\n";
        $mail_body .= "$Name"."\r\n";
        $mail_body .= "$Addr"."\r\n";
        $mail_body .= "$City,". " $State". " $Zip"."\r\n";
        $mail_body .= "$Comments"."\r\n";
        //sending to
        $recipient = "hakarune@gmail.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: " . $Email . " <" . $Email . ">\r\n";
        //mail command
        mail($recipient, $subject, $mail_body, $header);
                                   }
          echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in a few moments...</div>";
                        //page redirect to home
                                         echo "<meta http-equiv=\"refresh\" content=\"4;url=";
                          echo "http://lmtl-linux/credit\" />";
}
  if (true == $show_form) {
?>

<form name="ordering" action="" method="GET" enctype="text/plain">
<img src="1.jpg" />
<input type="checkbox" name="pic[]" value="1">
<br />
<select name="Type" size="1" name="size[]" Value="1">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="2.jpg" />
<input type="checkbox" name="pic[]" value="2">
<br />
<select name="Type" size="1" name="size[]" Value="2">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="3.jpg" />
<input type="checkbox" name="size[]" Value="3">
<br />
<select name="Type" size="1" name="size3">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="4.jpg" />
<input type="checkbox" name="pic[]" value="4">
<br />
<select name="Type" size="1" name="size[]" Value="4">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="5.jpg" />
<input type="checkbox" name="pic[]" value="5">
<br />
<select name="Type" size="1" name="size[]" Value="5">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<br />
<br />
Information For Invoice: <font color="red">(Required Info = *)</font>
<br />
<input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font 

color="red">*</font>
<input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font 

color="red">*</font>
<br />
<input type="text" name="phone" Value="Phone Number" size="25" onfocus="value=''">
<br />
<input type="text" name="email" Value="E-mail" size="30" onfocus="value=''">
<br />
<input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font 

color="red">*</font>
<br />
<input type="text" name="city" Value="city" size="30" onfocus="value=''"><font 

color="red">*</font>
<br />
<select name="state" size="1">
	<option value="">Select State</option>
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select>
<br />
<input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font 

color="red">*</font>
<br />
<textarea name="comments" rows="15" cols="40" value="comments" onfocus="value=''">
  </textarea>
<br />
<input type=button value="Submit">
<input type="reset" value="Clear Form">
</form>
<?php
      }//true == $show_form
?>

Can you post the code for formvalidator.php? It seems as though the error may be there, from a glance.

Can you post the code for formvalidator.php? It seems as though the error may be there, from a glance.

<?PHP
class ValidatorObj
{
	var $variable_name;
	var $validator_string;
	var $error_string;
}

/**
* Base class for custom validation objects
**/
class CustomValidator 
{
	function DoValidate(&$formars,&$error_hash)
	{
		return true;
	}
}

/** Default error messages*/
define("E_VAL_REQUIRED_VALUE","Please enter the value for %s");
define("E_VAL_MAXLEN_EXCEEDED","Maximum length exceeded for %s.");
define("E_VAL_MINLEN_CHECK_FAILED","Please enter input with length more than %d for %s");
define("E_VAL_ALNUM_CHECK_FAILED","Please provide an alpha-numeric input for %s");
define("E_VAL_ALNUM_S_CHECK_FAILED","Please provide an alpha-numeric input for %s");
define("E_VAL_NUM_CHECK_FAILED","Please provide numeric input for %s");
define("E_VAL_ALPHA_CHECK_FAILED","Please provide alphabetic input for %s");
define("E_VAL_ALPHA_S_CHECK_FAILED","Please provide alphabetic input for %s");
define("E_VAL_EMAIL_CHECK_FAILED","Please provide a valida email address");
define("E_VAL_LESSTHAN_CHECK_FAILED","Enter a value less than %f for %s");
define("E_VAL_GREATERTHAN_CHECK_FAILED","Enter a value greater than %f for %s");
define("E_VAL_REGEXP_CHECK_FAILED","Please provide a valid input for %s");
define("E_VAL_DONTSEL_CHECK_FAILED","Wrong option selected for %s");
define("E_VAL_SELMIN_CHECK_FAILED","Please select minimum %d options for %s");
define("E_VAL_SELONE_CHECK_FAILED","Please select an option for %s");
define("E_VAL_EQELMNT_CHECK_FAILED","Value of %s should be same as that of %s");
define("E_VAL_NEELMNT_CHECK_FAILED","Value of %s should not be same as that of %s");



/**
* FormValidator: The main class that does all the form validations
**/
class FormValidator 
{
	var $validator_array;
    var $error_hash;
	var $custom_validators;
	
	function FormValidator()
	{
		$this->validator_array = array();
        $this->error_hash = array();
		$this->custom_validators=array();
	}
	
	function AddCustomValidator(&$customv)
	{
		array_push($this->custom_validators,$customv);
	}

	function addValidation($variable,$validator,$error)
	{
		$validator_obj = new ValidatorObj();
		$validator_obj->variable_name = $variable;
		$validator_obj->validator_string = $validator;
		$validator_obj->error_string = $error;
		array_push($this->validator_array,$validator_obj);
	}
    function GetErrors()
    {
        return $this->error_hash;
    }

	function ValidateForm()
	{
		$bret = true;

		$error_string="";
		$error_to_display = "";

        
		if(strcmp($_SERVER['REQUEST_METHOD'],'POST')==0)
		{
			$form_variables = $_POST;
		}
		else
		{
			$form_variables = $_GET;
		}

        $vcount = count($this->validator_array);
        

		foreach($this->validator_array as $val_obj)
		{
			if(!$this->ValidateObject($val_obj,$form_variables,$error_string))
			{
				$bret = false;
                $this->error_hash[$val_obj->variable_name] = $error_string;
			}
		}

		if(true == $bret && count($this->custom_validators) > 0)
		{
            foreach( $this->custom_validators as $custom_val)
			{
				if(false == $custom_val->DoValidate($form_variables,$this->error_hash))
				{
					$bret = false;
				}
			}
		}
		return $bret;
	}


	function ValidateObject($validatorobj,$formvariables,&$error_string)
	{
		$bret = true;

		$splitted = explode("=",$validatorobj->validator_string);
		$command = $splitted[0];
		$command_value = '';

		if(isset($splitted[1]) && strlen($splitted[1])>0)
		{
			$command_value = $splitted[1];
		}

		$default_error_message="";
		
		$input_value ="";

		if(isset($formvariables[$validatorobj->variable_name]))
		{
		 $input_value = $formvariables[$validatorobj->variable_name];
		}

		$bret = $this->ValidateCommand($command,$command_value,$input_value,
									$default_error_message,
									$validatorobj->variable_name,
									$formvariables);

		
		if(false == $bret)
		{
			if(isset($validatorobj->error_string) &&
				strlen($validatorobj->error_string)>0)
			{
				$error_string = $validatorobj->error_string;
			}
			else
			{
				$error_string = $default_error_message;
			}

		}//if
		return $bret;
	}
    	
	function validate_req($input_value, &$default_error_message,$variable_name)
	{
	  $bret = true;
      	if(!isset($input_value) ||
			strlen($input_value) <=0)
		{
			$bret=false;
			$default_error_message = sprintf(E_VAL_REQUIRED_VALUE,$variable_name);
		}	
	  return $bret;	
	}

	function validate_maxlen($input_value,$max_len,$variable_name,&$default_error_message)
	{
		$bret = true;
		if(isset($input_value) )
		{
			$input_length = strlen($input_value);
			if($input_length > $max_len)
			{
				$bret=false;
				$default_error_message = sprintf(E_VAL_MAXLEN_EXCEEDED,$variable_name);
			}
		}
		return $bret;
	}

	function validate_minlen($input_value,$min_len,$variable_name,&$default_error_message)
	{
		$bret = true;
		if(isset($input_value) )
		{
			$input_length = strlen($input_value);
			if($input_length < $min_len)
			{
				$bret=false;
				$default_error_message = sprintf(E_VAL_MINLEN_CHECK_FAILED,$min_len,$variable_name);
			}
		}
		return $bret;
	}

	function test_datatype($input_value,$reg_exp)
	{
		if(ereg($reg_exp,$input_value))
		{
			return false;
		}
		return true;
	}

	function validate_email($email) 
	{
		return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);
	}

	function validate_for_numeric_input($input_value,&$validation_success)
	{
		
		$more_validations=true;
		$validation_success = true;
		if(strlen($input_value)>0)
		{
			
			if(false == is_numeric($input_value))
			{
				$validation_success = false;
				$more_validations=false;
			}
		}
		else
		{
			$more_validations=false;
		}
		return $more_validations;
	}

	function validate_lessthan($command_value,$input_value,
                $variable_name,&$default_error_message)
	{
		$bret = true;
		if(false == $this->validate_for_numeric_input($input_value,
                                    $bret))
		{
			return $bret;
		}
		if($bret)
		{
			$lessthan = doubleval($command_value);
			$float_inputval = doubleval($input_value);
			if($float_inputval >= $lessthan)
			{
				$default_error_message = sprintf(E_VAL_LESSTHAN_CHECK_FAILED,
										$lessthan,
										$variable_name);
				$bret = false;
			}//if
		}
		return $bret ;
	}

	function validate_greaterthan($command_value,$input_value,$variable_name,&$default_error_message)
	{
		$bret = true;
		if(false == $this->validate_for_numeric_input($input_value,$bret))
		{
			return $bret;
		}
		if($bret)
		{
			$greaterthan = doubleval($command_value);
			$float_inputval = doubleval($input_value);
			if($float_inputval <= $greaterthan)
			{
				$default_error_message = sprintf(E_VAL_GREATERTHAN_CHECK_FAILED,
										$greaterthan,
										$variable_name);
				$bret = false;
			}//if
		}
		return $bret ;
	}

    function validate_select($input_value,$command_value,&$default_error_message,$variable_name)
    {
	    $bret=false;
		if(is_array($input_value))
		{
			foreach($input_value as $value)
			{
				if($value == $command_value)
				{
					$bret=true;
					break;
				}
			}
		}
		else
		{
			if($command_value == $input_value)
			{
				$bret=true;
			}
		}
        if(false == $bret)
        {
            $default_error_message = sprintf(E_VAL_SHOULD_SEL_CHECK_FAILED,
                                            $command_value,$variable_name);
        }
	    return $bret;
    }

	function validate_dontselect($input_value,$command_value,&$default_error_message,$variable_name)
	{
	   $bret=true;
		if(is_array($input_value))
		{
			foreach($input_value as $value)
			{
				if($value == $command_value)
				{
					$bret=false;
					$default_error_message = sprintf(E_VAL_DONTSEL_CHECK_FAILED,$variable_name);
					break;
				}
			}
		}
		else
		{
			if($command_value == $input_value)
			{
				$bret=false;
				$default_error_message = sprintf(E_VAL_DONTSEL_CHECK_FAILED,$variable_name);
			}
		}
	  return $bret;
	}



	function ValidateCommand($command,$command_value,$input_value,&$default_error_message,$variable_name,$formvariables)
	{
		$bret=true;
		switch($command)
		{
			case 'req':
						{
							$bret = $this->validate_req($input_value, $default_error_message,$variable_name);
							break;
						}

			case 'maxlen':
						{
							$max_len = intval($command_value);
							$bret = $this->validate_maxlen($input_value,$max_len,$variable_name,
												$default_error_message);
							break;
						}

			case 'minlen':
						{
							$min_len = intval($command_value);
							$bret = $this->validate_minlen($input_value,$min_len,$variable_name,
											$default_error_message);
							break;
						}

			case 'alnum':
						{
							$bret= $this->test_datatype($input_value,"[^A-Za-z0-9]");
							if(false == $bret)
							{
								$default_error_message = sprintf(E_VAL_ALNUM_CHECK_FAILED,$variable_name);
							}
							break;
						}

			case 'alnum_s':
						{
							$bret= $this->test_datatype($input_value,"[^A-Za-z0-9 ]");
							if(false == $bret)
							{
								$default_error_message = sprintf(E_VAL_ALNUM_S_CHECK_FAILED,$variable_name);
							}
							break;
						}

			case 'num':
            case 'numeric':
						{
							$bret= $this->test_datatype($input_value,"[^0-9]");
							if(false == $bret)
							{
								$default_error_message = sprintf(E_VAL_NUM_CHECK_FAILED,$variable_name);
							}
							break;							
						}

			case 'alpha':
						{
							$bret= $this->test_datatype($input_value,"[^A-Za-z]");
							if(false == $bret)
							{
								$default_error_message = sprintf(E_VAL_ALPHA_CHECK_FAILED,$variable_name);
							}
							break;
						}
			case 'alpha_s':
						{
							$bret= $this->test_datatype($input_value,"[^A-Za-z ]");
							if(false == $bret)
							{
								$default_error_message = sprintf(E_VAL_ALPHA_S_CHECK_FAILED,$variable_name);
							}
							break;
						}
			case 'email':
						{
							if(isset($input_value) && strlen($input_value)>0)
							{
								$bret= $this->validate_email($input_value);
								if(false == $bret)
								{
									$default_error_message = E_VAL_EMAIL_CHECK_FAILED;
								}
							}
							break;
						}
			case "lt": 
			case "lessthan": 
						{
							$bret = $this->validate_lessthan($command_value,
													$input_value,
													$variable_name,
													$default_error_message);
							break;
						}
			case "gt": 
			case "greaterthan": 
						{
							$bret = $this->validate_greaterthan($command_value,
													$input_value,
													$variable_name,
													$default_error_message);
							break;
						}

			case "regexp":
						{
							if(isset($input_value) && strlen($input_value)>0)
							{
								if(!preg_match("$command_value",$input_value))
								{
									$bret=false;
									$default_error_message = sprintf(E_VAL_REGEXP_CHECK_FAILED,$variable_name);
								}
							}
							break;
						}
		  case "dontselect": 
		  case "dontselectchk":
          case "dontselectradio":
						{
							$bret = $this->validate_dontselect($input_value,
															   $command_value,
															   $default_error_message,
																$variable_name);
							 break;
						}//case

          case "shouldselchk":
          case "selectradio":
                      {
                            $bret = $this->validate_select($input_value,
							       $command_value,
							       $default_error_message,
								    $variable_name);
                            break;
                      }//case
		  case "selmin":
						{
							$min_count = intval($command_value);

							if(isset($input_value))
                            {
							    if($min_count > 1)
							    {
							        $bret = (count($input_value) >= $min_count )?true:false;
							    }
                                else
                                {
                                  $bret = true;
                                }
                            }
							else
							{
								$bret= false;
								$default_error_message = sprintf(E_VAL_SELMIN_CHECK_FAILED,$min_count,$variable_name);
							}

							break;
						}//case
		 case "selone":
						{
							if(false == isset($input_value)||
								strlen($input_value)<=0)
							{
								$bret= false;
								$default_error_message = sprintf(E_VAL_SELONE_CHECK_FAILED,$variable_name);
							}
							break;
						}
		 case "eqelmnt":
						{

							if(isset($formvariables[$command_value]) &&
							   strcmp($input_value,$formvariables[$command_value])==0 )
							{
								$bret=true;
							}
							else
							{
								$bret= false;
								$default_error_message = sprintf(E_VAL_EQELMNT_CHECK_FAILED,$variable_name,$command_value);
							}
						break;
						}
		  case "neelmnt":
						{
							if(isset($formvariables[$command_value]) &&
							   strcmp($input_value,$formvariables[$command_value]) !=0 )
							{
								$bret=true;
							}
							else
							{
								$bret= false;
								$default_error_message = sprintf(E_VAL_NEELMNT_CHECK_FAILED,$variable_name,$command_value);
							}
							break;
						}
		 
		}//switch
		return $bret;
	}//validdate command


}
?>

Line 246 in the code in your first post should be:

<input type="Submit" value="Submit">

I changed that and the button actually does something when clicked, but still not seeing any form validation. When I click "Submit", the page just reloads and the form is reset- the only difference is that the URL changes. Maybe you need to make sure you're using $_POST[] properly in order to validate those values?

Ok, I have the form at least working, sorta....

the problem now is apparently the formvalidator.php

On submit it actually takes a sec and loads but the gives this:

( ! ) Deprecated: Function eregi() is deprecated in C:\Users\Portgas D Ace\Documents\My Web Sites\Bristow Galleries\orderform\formvalidator.php on line 235
Call Stack
# Time Memory Function Location
1 0.0203 372936 {main}( ) ..\buttontest3.php:0
2 0.0232 508008 FormValidator->ValidateForm( ) ..\buttontest3.php:33
3 0.0233 508168 FormValidator->ValidateObject( $validatorobj = class ValidatorObj { public $variable_name = 'email'; public $validator_string = 'email'; public $error_string = '<B>Email address is invalid.</B>' }, $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' '), $error_string = '' ) ..\formvalidator.php:117
4 0.0233 508512 FormValidator->ValidateCommand( $command = 'email', $command_value = '', $input_value = 'E-mail', $default_error_message = '', $variable_name = 'email', $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' ') ) ..\formvalidator.php:163
5 0.0234 508544 FormValidator->validate_email( $email = 'E-mail' ) ..\formvalidator.php:442
Dump $_SERVER
$_SERVER =
string '127.0.0.1' (length=9)
$_SERVER =
string 'POST' (length=4)
$_SERVER =
string '/bristowgalleries/orderform/buttontest3.php' (length=43)
Variables in local scope (#5)
$email =
string 'E-mail' (length=6)

( ! ) Deprecated: Function ereg() is deprecated in C:\Users\Portgas D Ace\Documents\My Web Sites\Bristow Galleries\orderform\formvalidator.php on line 226
Call Stack
# Time Memory Function Location
1 0.0203 372936 {main}( ) ..\buttontest3.php:0
2 0.0232 508008 FormValidator->ValidateForm( ) ..\buttontest3.php:33
3 0.0253 508512 FormValidator->ValidateObject( $validatorobj = class ValidatorObj { public $variable_name = 'zip'; public $validator_string = 'num'; public $error_string = '<B>Numbers only in Zipcode.</B>' }, $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' '), $error_string = '<B>Email address is invalid.</B>' ) ..\formvalidator.php:117
4 0.0254 508856 FormValidator->ValidateCommand( $command = 'num', $command_value = '', $input_value = 'Zipcode', $default_error_message = '', $variable_name = 'zip', $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' ') ) ..\formvalidator.php:163
5 0.0254 508936 FormValidator->test_datatype( $input_value = 'Zipcode', $reg_exp = '[^0-9]' ) ..\formvalidator.php:412
Variables in local scope (#5)
$input_value =
string 'Zipcode' (length=7)
$reg_exp =
string '[^0-9]' (length=6)

( ! ) Deprecated: Function ereg() is deprecated in formvalidator.php on line 226
Call Stack
# Time Memory Function Location
1 0.0203 372936 {main}( ) ..\buttontest3.php:0
2 0.0232 508008 FormValidator->ValidateForm( ) ..\buttontest3.php:33
3 0.0265 508624 FormValidator->ValidateObject( $validatorobj = class ValidatorObj { public $variable_name = 'phone'; public $validator_string = 'num'; public $error_string = '<B>Numbers only in phone number.</B>' }, $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' '), $error_string = '<B>Numbers only in Zipcode.</B>' ) ..\formvalidator.php:117
4 0.0265 508968 FormValidator->ValidateCommand( $command = 'num', $command_value = '', $input_value = 'Phone Number', $default_error_message = '', $variable_name = 'phone', $formvariables = array ('Type' => '', 'first' => 'First Name', 'last' => 'Last Name', 'phone' => 'Phone Number', 'email' => 'E-mail', 'addr' => 'Street Address', 'city' => 'city', 'state' => '', 'zip' => 'Zipcode', 'comments' => ' ') ) ..\formvalidator.php:163
5 0.0267 509048 FormValidator->test_datatype( $input_value = 'Phone Number', $reg_exp = '[^0-9]' ) ..\formvalidator.php:412
Variables in local scope (#5)
$input_value =
string 'Phone Number' (length=12)
$reg_exp =
string '[^0-9]' (length=6)
Validation Errors:
email : Email address is invalid.

zip : Numbers only in Zipcode.

phone : Numbers only in phone number.

Your order has been sent successfully.
An Invoice will be either emailed or mailed to you, thank you for your order.
You will be redirected to the home page in 10 seconds...


Information For Invoice: (Required Info = *)
* *


*
*

*

Line 226 is

if(ereg($reg_exp,$input_value))	{

and line 235 is

return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);

The prolbem here is I didn't write the formvalidator.php ... I got it from a tutorial site and far as I know I followed all the instructions for adding my info the right way... any help here?

Also new code for page:

<html>
<HEAD>
</head>
<body>
<?php
require_once "formvalidator.php";
  $error_hash = 'no';
  $show_form = true;
class MyValidator extends CustomValidator
{
	function DoValidate(&$formars,&$error_hash)
	{
        if(stristr($formars['comments'],'http://'))
        {
            $error_hash['comments']="No URLs allowed in comments";
            return false;
        }
		return true;
	}
}

  if ($_SERVER['REQUEST_METHOD'] == "POST") {

      $validator = new FormValidator();
      $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
      $validator->addValidation("first", "req", "<B>Please provide your first name for invoice.</B>");
      $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
      $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
      $validator->addValidation("zip", "req", "<B>Please provide your zipcode for invoice.</B>");
      $validator->addValidation("last", "req", "<B>Please provide your last name for invoice.</B>");
      $validator->addValidation("zip", "num", "<B>Numbers only in Zipcode.</B>");
      $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");
      if ($validator->ValidateForm()) {
          $show_form = false;
      } else {
          echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
          $error_hash = $validator->GetErrors();
          foreach ($error_hash as $inpname => $inp_err) {
              echo "<center><p>$inpname : $inp_err</p></center>\n";
              $show_form = true;
          }
      }
          if ($show_form === false){
          // Grab the form vars
	  $Pic = $_POST['pic[]'] ;
	  $Size = $_POST['size[]'] ;
          $Email = $_POST['email'];
          $Name = $_POST['first'. 'last'];
          $Addr = $_POST['addr'];
          $City = $_POST['city'];
          $State = $_POST['state'];
          $Zip = $_POST['zip'];
	  $comments = $_POST['comments'] ;
 
if(empty($pic)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  } 
  else 
  {
    $r = count($pic);
    for($i=0; $i < $r; $i++)
    {
      echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
    }
  }
if(empty($size)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
  } 
  else 
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
    }
  }

        //message body
        $mail_body .= "$Pic"."\r\n";
        $mail_body .= "$Size"."\r\n";
        $mail_body .= "$Email"."\r\n";
        $mail_body .= "$Name"."\r\n";
        $mail_body .= "$Addr"."\r\n";
        $mail_body .= "$City,". " $State". " $Zip"."\r\n";
        $mail_body .= "$Comments"."\r\n";
        //sending to
        $recipient = "hakarune@gmail.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: " . $Email . " <" . $Email . ">\r\n";
        //mail command
        mail($recipient, $subject, $mail_body, $header);
                                   }
          echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>";
                        //page redirect to home
                                         echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">";

}
  if (true == $show_form) {
?>

<form name="ordering" action="" method="POST">
<img src="1.jpg" />
<input type="checkbox" name="pic[]" value="1">
<br />
<select name="Type" size="1" name="size[]" Value="1">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="2.jpg" />
<input type="checkbox" name="pic[]" value="2">
<br />
<select name="Type" size="1" name="size[]" Value="2">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="3.jpg" />
<input type="checkbox" name="size[]" Value="3">
<br />
<select name="Type" size="1" name="size3">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="4.jpg" />
<input type="checkbox" name="pic[]" value="4">
<br />
<select name="Type" size="1" name="size[]" Value="4">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="5.jpg" />
<input type="checkbox" name="pic[]" value="5">
<br />
<select name="Type" size="1" name="size[]" Value="5">
  <option value="">Select Type</option>
  <option value="Original">Original $Price</option>
  <option value="Print Small">300x500 Print $Price</option>
 <option value="Print Medium">800x600 Print $Price</option>
 <option value="Print Large">1200x1280 Print $Price</option>
 <option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<br />
<br />
Information For Invoice: <font color="red">(Required Info = *)</font>
<br />
<input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font 

color="red">*</font>
<input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font 

color="red">*</font>
<br />
<input type="text" name="phone" Value="Phone Number" size="25" onfocus="value=''">
<br />
<input type="text" name="email" Value="E-mail" size="30" onfocus="value=''">
<br />
<input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font 

color="red">*</font>
<br />
<input type="text" name="city" Value="city" size="30" onfocus="value=''"><font 

color="red">*</font>
<br />
<select name="state" size="1">
	<option value="">Select State</option>
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select>
<br />
<input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font 

color="red">*</font>
<br />
<textarea name="comments" rows="15" cols="40" value="comments" onfocus="value=''">
  </textarea>
<br />
<input type="Submit" value="Submit">
<input type="reset" value="Clear Form">
</form>
<?php
      }//true == $show_form
?>
</body>
</html>

Still with ya- I will take a look at all of this tomorrow morning and let you know what I find.

Still with ya- I will take a look at all of this tomorrow morning and let you know what I find.

Thanks I'm actually about to post up the new code. Let me know if you can help fix the few problems I have still. Also I'm about to run a real trial on the actual server that has the ability to mail.


So here is what I have, everything seems to work fine, though I think I screwed up the message body by making ".=" just "=" as well as made ."\r\n\" into just ."\n" (I'll found out with the server test in a little bit.

Ok so the only current problems are:
#1 --> Can't validate Zip and phone to be numbers only
#2 --> Is a weird thing happening, I have this code:

$size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
if(empty($size)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
  } 
  else 
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
    }

with this html:

<select size="1" name="size[]">
  <option>Select Type</option>
  <option value="pic1_Original">Original $Price</option>
  <option value="pic1_300x500 Print">300x500 Print $Price</option>
  <option value="pic1_800x600 Print">800x600 Print $Price</option>
  <option value="pic1_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic1_1282x1400 Print">1282x1400 Print $Price</option>
</select>

and "Select Size" selected (value is empty) it shows:

picture(s) requested 0 was: 1 Sizes(s) requested 0 was: Select Type Sizes(s) requested 1 was: Select Type Sizes(s) requested 2 was: Select Type Sizes(s) requested 3 was: Select Type Sizes(s) requested 4 was: Select Type

below the errors and it shouldn't show at all... and shouldn't show blank values

<?php
require_once "formvalidator.php";
  $error_hash = 'no';
  $show_form = true;
  if ($_SERVER['REQUEST_METHOD'] == "POST") {

      $validator = new FormValidator();
      $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
      $validator->addValidation("name", "req", "<B>Please provide your First name for invoice.</B>");
      $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
      $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
      $validator->addValidation("state", "req", "<B>Please provide your State for invoice.</B>");
      $validator->addValidation("zip", "req", "<B>Please provide your zip for invoice.</B>");
      
      if ($validator->ValidateForm()) {
          $show_form = false;
      } else {
          echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
          $error_hash = $validator->GetErrors();
          foreach ($error_hash as $inpname => $inp_err) {
              echo "<center><p>$inpname : $inp_err</p></center>\n";
              $show_form = true;
          }
      }

$pic = isset($_POST['pic']) ? $_POST['pic'] : false;
if(empty($pic)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  } 
  else 
  {
    $r = count($pic);
    for($i=0; $i < $r; $i++)
    {
      echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
    }
  }

$size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
if(empty($size)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
  } 
 else
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
    }
  }


          if ($show_form === false){
          // Grab the form vars

          $email = $_POST['email'];
          $name = $_POST['name'];
          $addr = $_POST['addr'];
          $city = $_POST['city'];
          $state = $_POST['state'];
          $zip = $_POST['zip'];
	  $comments = $_POST['comments'] ;
 


        //message body
        $message = "$pic"."\n";
        $message = "$size"."\n";
        $message = "$email"."\n";
        $message = "$name"."\n";
        $message = "$addr"."n";
        $message = "$city,". " $state". " $zip"."\n";
        $message = "$comments"."\n";
        //sending to
        $recipient = "hakarune@gmail.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: " . $email . " <" . $email . ">\n";
        //mail command
        mail($recipient, $subject, $message, $header);
                                   
          echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>";
                        //page redirect to home
                                         echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">";
	
  }
}

  if (true == $show_form) {
?>

<form name="ordering" action="" method="POST">
<img src="1.jpg" />
<input type="checkbox" name="pic[]" value="1">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic1_Original">Original $Price</option>
  <option value="pic1_300x500 Print">300x500 Print $Price</option>
  <option value="pic1_800x600 Print">800x600 Print $Price</option>
  <option value="pic1_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic1_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="2.jpg" />
<input type="checkbox" name="pic[]" value="2">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic2_Original">Original $Price</option>
  <option value="pic2_300x500 Print">300x500 Print $Price</option>
  <option value="pic2_800x600 Print">800x600 Print $Price</option>
  <option value="pic2_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic2_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="3.jpg" />
<input type="checkbox" name="pic[]" Value="3">
<br />
<select nsize="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic3_Original">Original $Price</option>
  <option value="pic3_300x500 Print">300x500 Print $Price</option>
  <option value="pic3_800x600 Print">800x600 Print $Price</option>
  <option value="pic3_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic3_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="4.jpg" />
<input type="checkbox" name="pic[]" value="4">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic4_Original">Original $Price</option>
  <option value="pic4_300x500 Print">300x500 Print $Price</option>
  <option value="pic4_800x600 Print">800x600 Print $Price</option>
  <option value="pic4_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic4_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="5.jpg" />
<input type="checkbox" name="pic[]" value="5">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic5_Original">Original $Price</option>
  <option value="pic5_300x500 Print">300x500 Print $Price</option>
  <option value="pic5_800x600 Print">800x600 Print $Price</option>
  <option value="pic5_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic5_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<br />
<br />
Information For Invoice: <font color="red">(Required Info = *)</font>
<br />
First & Last Name:<input type="text" name="name" Value="" size="25" onfocus="value=''"><font color="red">*</font>
<br />
Phone:<input type="text" name="phone" Value="" size="25" onfocus="value=''">
<br />
E-Mail:<input type="text" name="email" Value="E-mail@example.com" size="30" onfocus="value=''">
<br />
Address:<input type="text" name="addr" Value="" size="50" onfocus="value=''"><font 

color="red">*</font>
<br />
City:<input type="text" name="city" Value="" size="30" onfocus="value=''"><font 

color="red">*</font>
<br />
<select name="state" size="1">
	<option value="">Select State</option>
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select><font color="red">*</font>
<br />
Zipcode:<input type="text" name="zip" Value="" size="5" onfocus="value=''"><font color="red">*</font>
<br />
<textarea name="comments" rows="5" cols="20" value="comments" onfocus="value=''">
  </textarea>
<br />
<input type="Submit" value="Submit">
<input type="reset" value="Clear Form">
</form>
<?php
      }//true == $show_form
?>

Still looking through all of this, but here's what I'm thinking so far:

-You said you can't validate phone and zip to be numbers. Phone fields are tricky, because they have so many ways people input them, like whether they use dashes, parenthesis, spaces, etc. Your code is missing something that can take the user-input for the "Phone" field and strip out all the characters but the numbers, and then make sure there are the 10 digits. Currently, I'm not seeing anything in your script that validates phone numbers (maybe I'm missing it- if there is, can you tell me where that happens in the code), and there is also nothing that uses $_POST so that would definitely be a reason for phone numbers not validating.

I also see that you don't have "Phone" marked as a required field, so you will also need something like...

$phone = isset($_POST['phone']) ? $_POST['phone'] : false;
if (!empty($phone)) {
     $phone = preg_replace('/\D/', '', $phone);
}

Also, a simple way to validate phone and zip is a simple less than/greater than check:

if ($phone > 9999999999 | $phone < 1111111111) {
     //Whatever should happen if the phone number is invalid
}

That would work for zip codes too, if you use 5 digits (eg. 99999) instead of 10. Sort of a workaround, but I feel it gets the job done.

That's all for now, but I'm still looking into your second issue. One thing I noticed while testing your code is that you don't get that problem if there is a problem with validating the required fields (so currently if you didn't enter a name and you also didn't select a picture, there is a proper error message telling you to select a picture). But if the rest of the form was filled out correctly except that no pictures were selected, then I am able to reproduce the problem you posted. I'll let you know what I find.

Oh, but maybe a simple solution would be something that just makes sure that at least one image is selected before it does anything else, since that's essentially the main purpose of the form. If no images were selected, I wouldn't worry about validating anything else- just let the user know that they didn't select an image.

Alternatively, you could use javascript to disable the "Submit" button until an image has been selected, or alert the user and don't send the form if they press "Submit" without selecting an image.

Still looking through all of this, but here's what I'm thinking so far:

-You said you can't validate phone and zip to be numbers. Phone fields are tricky, because they have so many ways people input them, like whether they use dashes, parenthesis, spaces, etc. Your code is missing something that can take the user-input for the "Phone" field and strip out all the characters but the numbers, and then make sure there are the 10 digits. Currently, I'm not seeing anything in your script that validates phone numbers (maybe I'm missing it- if there is, can you tell me where that happens in the code), and there is also nothing that uses $_POST so that would definitely be a reason for phone numbers not validating.

I also see that you don't have "Phone" marked as a required field, so you will also need something like...

$phone = isset($_POST['phone']) ? $_POST['phone'] : false;
if (!empty($phone)) {
     $phone = preg_replace('/\D/', '', $phone);
}

Also, a simple way to validate phone and zip is a simple less than/greater than check:

if ($phone > 9999999999 | $phone < 1111111111) {
     //Whatever should happen if the phone number is invalid
}

That would work for zip codes too, if you use 5 digits (eg. 99999) instead of 10. Sort of a workaround, but I feel it gets the job done.

That's all for now, but I'm still looking into your second issue. One thing I noticed while testing your code is that you don't get that problem if there is a problem with validating the required fields (so currently if you didn't enter a name and you also didn't select a picture, there is a proper error message telling you to select a picture). But if the rest of the form was filled out correctly except that no pictures were selected, then I am able to reproduce the problem you posted. I'll let you know what I find.

Yeah phone number isn't a required field, but an optional one. As for the validation, on lines 31 && 32 is where it's supposed to be using using "num" from formvalidator.php but it doesn't work.

$validator->addValidation("zip", "num", "<B>Numbers only in Zipcode.</B>");
      $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");

Sweet. That validation you wrote will work great! not sure why I didn't think of doing that to begin with....


So yeah awesome, by the way the testing last night wet great. The only problems I ran into were:
#1: Pic and Size arrays weren't being emailed all I was getting from them was the word "array"
#2: The array for size is echoing all including "null" data and just shows up as

You Ordered pic1_800x600 Print
You Ordered
You Ordered
You Ordered
You Ordered

#3: Super slow email delivery from godaddy.com

Those were the only 2 real problems, the email is prob godaddy.com, just no clue how to fix it.... I also did change the code some more to make it work right. I'm going to through your code in too as well and make another test run when the site owner gets home.

<html>
<HEAD>
</head>
<body>
<?php
require_once "formvalidator.php";
  $error_hash = 'no';
  $show_form = true;
  if ($_SERVER['REQUEST_METHOD'] == "POST") {

      $validator = new FormValidator();
      $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
      $validator->addValidation("name", "req", "<B>Please provide your First name for invoice.</B>");
      $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
      $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
      $validator->addValidation("state", "req", "<B>Please provide your State for invoice.</B>");
      $validator->addValidation("zip", "req", "<B>Please provide your zip for invoice.</B>");
      
      if ($validator->ValidateForm()) {
          $show_form = false;
      } else {
          echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
          $error_hash = $validator->GetErrors();
          foreach ($error_hash as $inpname => $inp_err) {
              echo "<center><p>$inpname : $inp_err</p></center>\n";
              $show_form = true;
          }
      }
$phone = isset($_POST['phone']) ? $_POST['phone'] : false;
if (!empty($phone)) {
     $phone = preg_replace('/\D/', '', $phone);
}
if ($phone > 9999999999 | $phone < 1111111111) {
     echo "<center>phone:<B>Please provide a real phone #.</B></center> <br />";
}
$zip = isset($_POST['zip']) ? $_POST['zip'] : false;
if (!empty($zip)) {
     $zip = preg_replace('/\D/', '', $zip);
}
if ($zip > 99999 | $zip < 11111) {     
     echo "<center>zip:<B>Please provide a real zip for invoice.</B></center>";
}

$pic = isset($_POST['pic']) ? $_POST['pic'] : false;
if(empty($pic)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  } 
  else 
  {
    $r = count($pic);
    for($i=0; $i < $r; $i++)
    {
      echo "You Ordered " . $pic[$i], '<br />' . "\r\n";
    }
  }

$size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
if(empty($size)) 
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
  } 
 else
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      echo "You Ordered " . $size[$i], '<br />' . "\r\n";
    }
  }


          if ($show_form === false){
          // Grab the form vars

          $email = $_POST['email'];
          $name = $_POST['name'];
          $addr = $_POST['addr'];
          $city = $_POST['city'];
          $state = $_POST['state'];
          $zip = $_POST['zip'];
	  $comments = $_POST['comments'] ;
 


        //message body
        $message .= "$pic[$i]"."\r\n";
        $message .= "$size[$i]"."\r\n";
        $message .= "$email"."\r\n";
        $message .= "$name"."\r\n";
        $message .= "$addr"."\rn";
        $message .= "$city,". " $state". " $zip"."\r\n";
        $message .= "$comments"."\r\n";
        //sending to
        $recipient = "nicholas@bristowgalleris.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: nicholas@bristowgalleris.com">"\r\n";
        //mail command
        mail($recipient, $subject, $message, $header);
                                   
          echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>";
                        //page redirect to home
                                         echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">";
	
  }
}

  if (true == $show_form) {
?>

<form name="ordering" action="" method="POST">
<img src="1.jpg" />
<input type="checkbox" name="pic[]" value="pic1">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic1_Original">Original $Price</option>
  <option value="pic1_300x500 Print">300x500 Print $Price</option>
  <option value="pic1_800x600 Print">800x600 Print $Price</option>
  <option value="pic1_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic1_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="2.jpg" />
<input type="checkbox" name="pic[]" value="pic2">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic2_Original">Original $Price</option>
  <option value="pic2_300x500 Print">300x500 Print $Price</option>
  <option value="pic2_800x600 Print">800x600 Print $Price</option>
  <option value="pic2_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic2_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="3.jpg" />
<input type="checkbox" name="pic[]" Value="pic3">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic3_Original">Original $Price</option>
  <option value="pic3_300x500 Print">300x500 Print $Price</option>
  <option value="pic3_800x600 Print">800x600 Print $Price</option>
  <option value="pic3_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic3_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="4.jpg" />
<input type="checkbox" name="pic[]" value="pic4">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic4_Original">Original $Price</option>
  <option value="pic4_300x500 Print">300x500 Print $Price</option>
  <option value="pic4_800x600 Print">800x600 Print $Price</option>
  <option value="pic4_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic4_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<img src="5.jpg" />
<input type="checkbox" name="pic[]" value="pic5">
<br />
<select size="1" name="size[]">
  <option value="">Select Type</option>
  <option value="pic5_Original">Original $Price</option>
  <option value="pic5_300x500 Print">300x500 Print $Price</option>
  <option value="pic5_800x600 Print">800x600 Print $Price</option>
  <option value="pic5_1200x1280 Print">1200x1280 Print $Price</option>
  <option value="pic5_1282x1400 Print">1282x1400 Print $Price</option>
</select>
<br />
<br />
<br />
Information For Invoice: <font color="red">(Required Info = *)</font>
<br />
First & Last Name:<input type="text" name="name" Value="" size="25" onfocus="value=''"><font color="red">*</font>
<br />
Phone:<input type="text" name="phone" Value="(555)555-5555" size="13" onfocus="value=''">
<br />
E-Mail:<input type="text" name="email" Value="E-mail@example.com" size="30" onfocus="value=''">
<br />
Address:<input type="text" name="addr" Value="" size="50" onfocus="value=''"><font 

color="red">*</font>
<br />
City:<input type="text" name="city" Value="" size="30" onfocus="value=''"><font 

color="red">*</font>
<br />
<select name="state" size="1">
	<option value="">Select State</option>
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select><font color="red">*</font>
<br />
Zipcode:<input type="text" name="zip" Value="55555" size="5" onfocus="value=''"><font color="red">*</font>
<br />
<textarea name="comments" rows="5" cols="20" value="comments" onfocus="value=''">
  </textarea>
<br />
<input type="Submit" value="Submit">
<input type="reset" value="Clear Form">
</form>
<?php
      }//true == $show_form
?>
</body>
</html>

Your for() loop on lines 66-69 is iterating through all of the sizes, not just the ones that were selected with a pic[] checkbox. You need a way to only have the size[] array include the pictures that were checked. Right now, your checkboxes and lists are not "linked" in any way. Honestly, I don't know that you need the checkboxes unless you use them to disable the dropdown lists until they are checked (with javascript or something). I don't think you need them to process your form, but if you want them, they should be used for something like "You ordered x picture(s)."

I don't think I'm being clear, so let me explain another way: Your problems appear to be from 44-70. Here is what I would change:

$pic = isset($_POST['pic']) ? $_POST['pic'] : false;
if(empty($pic))
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  }
  else
  {
    $num_pics = count($pic);
    echo "You Ordered " . $num_pics . " pictures:", '<br />' . "\r\n";
  }

$size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
if(empty($size))
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>";
  }
 else
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      if (!empty($size[$i])) {
        echo $size[$i], '<br />' . "\r\n";
      }
    }
  }

The extra if() statement I added is to evaluate whether it should echo "You ordered", depending on whether that particular picture was selected (if that value in size[] is not empty). Try it and see how it works for you.

Also, a potential issue I noticed is that if I click more checkboxes than I make list selections for (ie. 3 checkboxes but only make a selection from two of the corresponding dropdowns), there is no error message that alerts me to that. Just FYI. To fix it, you'll probably need an if statement that displays an error message unless $num_pics == $r.

Ths code worked great, but for some reason, when I setup the email

if ($show_form === false){
          // Grab the form vars
 
          $email = $_POST['email'];
          $name = $_POST['name'];
          $addr = $_POST['addr'];
          $city = $_POST['city'];
          $state = $_POST['state'];
          $zip = $_POST['zip'];
	  $comments = $_POST['comments'] ;
 
 
 
        //message body
        $message .= "$num_pics"."\r\n";
        $message .= "$size[$i]"."\r\n";
        $message .= "$email"."\r\n";
        $message .= "$name"."\r\n";
        $message .= "$addr"."\rn";
        $message .= "$city,". " $state". " $zip"."\r\n";
        $message .= "$comments"."\r\n";
        //sending to
        $recipient = "nicholas@bristowgalleris.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: nicholas@bristowgalleris.com">"\r\n";
        //mail command
        mail($recipient, $subject, $message, $header);

all the email recieves about the pics and sizes is:
"1"
"1"
"email"
"name"
etc...

why is it only sending a "1" for the info on size and number of pices... it's like all it's sending is that the variables have info and that's it, it's not storing the info.....

Any ideas?

Try this (the code I posted, with 2 extra variable assignments):

$pic = isset($_POST['pic']) ? $_POST['pic'] : false;
if(empty($pic))
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
  }
  else
  {
    $num_pics = count($pic);
    $num_pics_msg = "You Ordered " . $num_pics . " pictures:", '<br />' . "\r\n";  //Add this
    echo $num_pics_msg; //Change to this
  }

$size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
if(empty($size))
  {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>";
  }
 else
  {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
      if (!empty($size[$i])) {
        echo $size[$i], '<br />' . "\r\n";
        $size_msg = $size_msg.$size[$i]."<br />"."\r\n"; //Add this
      }
    }
  }

Then

if ($show_form === false){
          // Grab the form vars
 
          $email = $_POST['email'];
          $name = $_POST['name'];
          $addr = $_POST['addr'];
          $city = $_POST['city'];
          $state = $_POST['state'];
          $zip = $_POST['zip'];
	  $comments = $_POST['comments'] ;
 
 
 
        //message body
        $message .= $num_pics_msg."\r\n";  //Change this
        $message .= $size_msg;  //Change this
        $message .= "$email"."\r\n";
        $message .= "$name"."\r\n";
        $message .= "$addr"."\rn";
        $message .= "$city,". " $state". " $zip"."\r\n";
        $message .= "$comments"."\r\n";
        //sending to
        $recipient = "nicholas@bristowgalleris.com";
        $subject = "Order Form";
        //Headerfields
        $header = "From: nicholas@bristowgalleris.com">"\r\n";
        //mail command
        mail($recipient, $subject, $message, $header);

Does that work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.