rvanness wrote:

I enclose all of the PHP code within a pair of {} braces because that is the way my teacher taught me.

Interesting. You might ask your teacher why this is so, and why you shouldn't include 2, 3, or even 342 {} braces around all of the PHP code, since they essentially have no effect other than to add to the confusion of matching up a { with its associated }. :p

rvanness wrote:

my captcha says to do that

Well in that case, you should tell the authors of the documentation that they aren't very careful in writing thorough documentation.

Too many times, documentation intends to scare end users into thinking that if session_start() isn't on the very absolute 1st line of their code then everything will break, your wife will leave you, and God will aim a lightning bolt at you. Okay, maybe they don't all say that, but it sure seems like it.

The only thing you need to do is make sure that [man]session_start/man (and any other function that modifies the HTTP headers, such as [man]header/man) is called before any output. The reason I chided the authors of the documentation you referenced is that they failed to mention the fact that the line break after the closing '?>' on that first line is output, meaning HTTP headers are then sent after line #1 (which means you can't call [man]header/man or similar functions on lines 2 through the end of your code).

Long story short: get rid of the closing '?>' on the first line (and the opening '<?php' on the next, of course). [man]session_start/man does not have to be on the first line of a PHP script, nor should you open and close PHP tags unless you actually mean to insert plain text data at that point.

    I have removed the {} surrounding my code and i still get the same error. Every day that this is down i lose $117.78. So please help me.

    <?php session_start(); ?>
    <?php
    
    
    
    
    include_once $_SERVER['DOCUMENT_ROOT'] . '/rvanness/validation/captcha/securimage/securimage.php';
    
    $securimage = new Securimage();
    
      $firstname = $_REQUEST['FirstName'] ;
      $lastname = $_REQUEST['LastName'] ;
      $email = $_REQUEST['Email'] ;
      $phoneday = $_REQUEST['PhoneDay'] ;
      $phoneevening = $_REQUEST['PhoneEvening'] ;
      $city = $_REQUEST['City'] ;
      $state = $_REQUEST['State'] ;
      $zipcode = $_REQUEST['ZipCode'] ;
      $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
      $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
      $aboveyes = $_REQUEST['aboveyes'] ;
      $shoppingcart = $_REQUEST['shoppingcart'] ;
      $howurgent = $_REQUEST['howurgent'] ;
      $comments = $_REQUEST['Comments'] ;
    
      function check_firstname($firstname)
     {
      if(!preg_match("/[^a-zA-Z]/",$firstname));
    	return TRUE;
       	return FALSE;
    }
    
     function check_lastname($lastname)
     {
      if(!preg_match("/[^a-zA-Z]/",$lastname))
      return TRUE;
      else
      return FALSE;
    }
    
    function checkEmail($email) 
    {
       if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
       {
          return FALSE;
       }
    
       list($Username, $Domain) = split("@",$email);
    
       if(getmxrr($Domain, $MXHost)) 
       {
          return TRUE;
       }
       else 
       {
          if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
          {
             return TRUE; 
          }
          else 
          {
             return FALSE; 
          }
       }
    }
    function validatePhoneNoday($phoneday)
    {
      if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
         return true;
      else
         return false;
    }
    function validatePhoneNonight($phoneevening)
    {
      if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
         return true;
      else
         return false;
    }
    function check_city($city)
     {
      if(!preg_match("/[^a-zA-Z]/",$city))
      return TRUE;
      else
      return FALSE;
    }
    function check_state($state)
     {
      if(!preg_match("/[^a-zA-Z]/",$state))
      return TRUE;
      else
      return FALSE;
    }
    function validateUSAZip($zipcode)
    {
      if(preg_match("/^([0-9]{5})(-[0-9]{4})?$/i",$zipcode))
        return true;
      else
        return false;
    }
    function webhostvalidate($doyouneedwebhosting)
    {
    if (empty($doyouneedwebhosting)) 
    	return false;
    else
    	return true;
    	}
    	function websitebuilt($doyouneedawebsitebuilt)
    	{
    	if (empty($doyouneedawebsitebuilt)) 
    	return false;
    else
    	return true;
    	}
    	function beforeyes($aboveyes)
    	{
    	if (empty($aboveyes)) 
    	return false;
    else
    	return true;
    	}
    	function shoppingcart($shoppingcart)
    		{
    	if (empty($shoppingcart)) 
    	return false;
    else
    	return true;
    	}
    	function urgent($howurgent)
    		{
    	if (empty($howurgent)) 
    	return false;
    else
    	return true;
    	}
    	function comments($comments)
    		{
    	if (empty($comments)) 
    	return false;
    else
    	return true;
    	}
    	/* Validation */
    
    $error=0; // check up variable
    
    /* get it checking */
    
    if(!check_firstname($firstname))
    {
      echo &#8220;Sorry, Non valid input /$firstname/ in FirstName&#8221;;
      $error++; // $error=$error+1;
    }
    if(!check_lastname($lastname))
    {
      echo &#8220;Illegal input /$lastname/ in &#8216;Last Name&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(checkEmail($email) == FALSE) 
    {
       echo "E-mail entered is not valid.";
       $error++; // $error=$error+1;
    } 
    if(!validatePhoneNoday($phoneday))
    {
      echo &#8220;Illegal input /$phoneday/ in &#8216;Phone Day&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!validatePhoneNonight($phoneevening))
    {
      echo &#8220;Illegal input /$phoneevening/ in &#8216;Phone evening&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!check_city($city))
    {
      echo &#8220;Illegal input /$city/ in &#8216;City&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!check_state($state))
    {
      echo &#8220;Illegal input /$state/ in &#8216;State&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!validateUSAZip($zipcode))
    {
      echo &#8220;Illegal input /$zipcode/ in &#8216;ZipCode&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!webhostvalidate($doyouneedwebhosting))
    {
      echo &#8220;Illegal input /$doyouneedwebhosting/ in Do you need web hosting&#8221;;
      $error++; // $error=$error+1;
    }
    if(!websitebuilt($doyouneedawebsitebuilt))
    {
      echo &#8220;Illegal input /$doyouneedawebsitebuilt/ in &#8216;Do you need a website built&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!beforeyes($aboveyes))
    {
      echo &#8220;Illegal input /$aboveyes/ in &#8216;If you answered yes to the above question do you know what the page should look like?&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!shoppingcart($shoppingcart))
    {
      echo &#8220;Illegal input /$shoppingcart/ in &#8216;Is this site going to have a shopping cart?&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if(!urgent($howurgent))
    {
      echo &#8220;Illegal input /$howurgent/ in &#8216;How urgent is this to you?&#8221;;
      $error++; // $error=$error+1;
    }
    if(!comments($comments))
    {
      echo &#8220;Illegal input /$comments/ in &#8216;Comments&#8217;&#8221;;
      $error++; // $error=$error+1;
    }
    if ($securimage->check($_POST['captcha_code']) == false) {
      // the code was incorrect
      // handle the error accordingly with your other error checking
    
      // or you can do something really basic like this
      die('The code you entered was incorrect.  Go back and try again.');
      $error++; // $error=$error+1;
    }
    if($error == 0)
    {
    //send email
    $to      = 'rvannessweb@live.com';
    $subject = 'webform';
      $name = $_REQUEST['FirstName'] ;
      $name .= $_REQUEST['LastName'] ;
      $email = $_REQUEST['Email'] ;
      $phoneday = $_REQUEST['PhoneDay'] ;
    $phoneevening = $_REQUEST['PhoneEvening'] ;
      $city = $_REQUEST['City'] ;
      $state = $_REQUEST['State'] ;
      $zipcode = $_REQUEST['ZipCode'] ;
      $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
      $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
      $aboveyes = $_REQUEST['aboveyes'] ;
      $shoppingcart = $_REQUEST['shoppingcart'] ;
      $howurgent = $_REQUEST['howurgent'] ;
    $comments = $_REQUEST['Comments'] ;
       $eol="\r\n"; // *****Try setting this one to \n if the \r\n does not send the mail *****
       $headers = 'From: Web form <rvannessweb@gmail.com>'.$eol;
    $headers .= 'Reply-To: Web form <rvannessweb@gmail.com>'.$eol;
    $headers .= 'Return-Path: Web form <rvannessweb@gmail.com>'.$eol;     // this one and the above to set reply address
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; // This creates a unique message ID
    $headers .= "X-Mailer: PHP v".phpversion().$eol;           // This and the above help avoid spam-filters
    
     //The message
    $msg = "A web quote has been submitted.\n" .
    	"Name: $name\n" .
    	"Email: $email\n" .
    	"Day time phone number: $phoneday\n" .
    	"Night time phone number: $phoneevening\n" .
    	"City: $city\n" .
    	"State: $state\n" .
    	"Zipcode: $zipcode\n" .
    	"Do you need web hosting?: $doyouneedwebhosting\n" .
    	"Do you need a web site built: $doyouneedawebsitebuilt\n" .
    	"If you answered yes to the above question do you know what the page should look like?: $aboveyes\n" .
    	"Is this site going to have a shopping cart?: $shoppingcart\n" .
    	"How urgent is this to you?: $howurgent\n" .
    	"Your comment: $comments";
    
     if(mail( $to, $subject, $msg, $headers))
    //Redirect
      header("Location: http://ccpsd.org/rvanness/");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    
    }
    else{
      echo &#8220;Number of errors: $error&#8221;;
    }
    ?>
    
      rvanness wrote:

      So please help me.

      Already did; read my first post above about removing the curly quotes.

      rvanness wrote:

      also i have another php validator that i wrote quickly starts the same and has the header() and it redirects just fine.

      If that is so, and you have the linebreak being outputted on the first line like you do above, then your server might have output buffering enabled for every PHP script by default, something I've never recommended since it means the server uses memory to buffer output for every request.

        Ok, I have done what bradgrafelman said and the only change is the line number
        Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /hsphere/local/home/c245363/ccpsd.org/rvanness/validation/webvalidator.php on line 149

          bradgrafelman below is my working validator

          <?php session_start(); ?>
          <?php
          
          
          
          {
          
          include_once $_SERVER['DOCUMENT_ROOT'] . '/rvanness/validation/captcha/securimage/securimage.php';
          
          $securimage = new Securimage();
          
          //Checks first name for authentication
          $firstname = $_POST['FirstName'];
          $firstnamevalid = eregi('[^a-zA-Z]', $firstname);
          $firstnamevalid = (int)$firstnamevalid;
          
          //Checks last name
          $lastname = $_POST['LastName'];
          $lastnamevalid = eregi('[^a-zA-Z]', $lastname);
          $lastnamevalid = (int)$lastnamevalid;
          
          //Checks Email Address
          $emailaddress = $_POST['Email'];
          $emailaddressvalid = eregi("[^a-z0-9@._]", $emailaddress);
          $emailaddressvalid = (int)$emailaddressvalid;
          
          //Check Phone number but no gaurrentee
          $phoneday = $_POST['PhoneDay'];
          $phonedayvalid = eregi('[0-9]{3}-[0-9]{3}-[0-9]{4}', $phoneday);
          $phonedayvalid = (int)$phonedayvalid;
          
          //Check Phone number but no gaurrentee
          $phoneevening = $_POST['PhoneEvening'];
          $phoneeveningvalid = eregi('[0-9]{3}-[0-9]{3}-[0-9]{4}', $phoneevening);
          $phoneeveningvalid = (int)$phoneeveningvalid;
          
          //Check the city
          $city = $_POST['City'];
          $cityvalid = eregi('[^a-zA-Z]', $city);
          $cityvalid = (int)$cityvalid;
          
          //Check State
          $state = $_POST['State'];
          $statevalid = eregi('[^a-zA-Z]', $state);
          $statevalid = (int)$statevalid;
          
          //Check Zipcode but no gaurrentee
          $zipcode = $_POST['ZipCode'];
          $zipcodevalid = eregi('[0-9]{5}', $zipcode);
          $zipcodevalid = (int)$zipcodevalid;
          
          //Now the statement
          if ($firstnamevalid == 0 && $lastnamevalid == 0 && $emailaddressvalid == 0 && $phonedayvalid == 1 && $phoneeveningvalid == 1 && $cityvalid == 0 && $statevalid == 0 && $zipcodevalid == 1) {
          //send email
          $to      = 'rvannessweb@live.com';
          $subject = 'webform';
            $name = $_REQUEST['FirstName'] ;
            $name .= $_REQUEST['LastName'] ;
            $email = $_REQUEST['Email'] ;
            $phoneday = $_REQUEST['PhoneDay'] ;
          $phoneevening = $_REQUEST['PhoneEvening'] ;
            $city = $_REQUEST['City'] ;
            $state = $_REQUEST['State'] ;
            $zipcode = $_REQUEST['ZipCode'] ;
            $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
            $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
            $aboveyes = $_REQUEST['aboveyes'] ;
            $shoppingcart = $_REQUEST['shoppingcart'] ;
            $howurgent = $_REQUEST['howurgent'] ;
          $comments = $_REQUEST['Comments'] ;
             $eol="\r\n"; // *****Try setting this one to \n if the \r\n does not send the mail *****
             $headers = 'From: Web form <rvannessweb@gmail.com>'.$eol;
          $headers .= 'Reply-To: Web form <rvannessweb@gmail.com>'.$eol;
          $headers .= 'Return-Path: Web form <rvannessweb@gmail.com>'.$eol;     // this one and the above to set reply address
          $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; // This creates a unique message ID
          $headers .= "X-Mailer: PHP v".phpversion().$eol;           // This and the above help avoid spam-filters
          
           //The message
          $msg = "A web quote has been submitted.\n" .
          	"Name: $name\n" .
          	"Email: $email\n" .
          	"Day time phone number: $phoneday\n" .
          	"Night time phone number: $phoneevening\n" .
          	"City: $city\n" .
          	"State: $state\n" .
          	"Zipcode: $zipcode\n" .
          	"Do you need web hosting?: $doyouneedwebhosting\n" .
          	"Do you need a web site built: $doyouneedawebsitebuilt\n" .
          	"If you answered yes to the above question do you know what the page should look like?: $aboveyes\n" .
          	"Is this site going to have a shopping cart?: $shoppingcart\n" .
          	"How urgent is this to you?: $howurgent\n" .
          	"Your comment: $comments";
          
           if(mail( $to, $subject, $msg, $headers))
          //Redirect
            header("Location: http://ccpsd.org/rvanness/");
          /* Make sure that code below does not get executed when we redirect. */
          exit;
           }
          
          
          // end validation
          
          // end submit
          else {
          echo "Sorry, the form failed.  Here's why: <ul>";
             if ($firstnamevalid == 1) {
          echo "<li>Your string contains invalid characters.  It can only contain letters and spaces.</li>";
          } if ($lastnamevalid == 1) {
          echo "<li>Your string contains invalid characters.  It can only contain letters and spaces.</li>";
          } if ($emailaddressvaild == 1) {
          echo "<li>That doesn't look like a valid address to me!</li>";
          } if ($phonedayvalid == 0) {
          echo "<li>Do you know your phone number?</li>";
          } if ($phoneeveningvalid == 0) {
          echo "<li>Do you know your phone number?</li>";
          } if ($cityvalid == 1) {
          echo "<li>Your string contains invalid characters.  It can only contain letters and spaces.</li>";
          } if ($statevalid == 1) {
          echo "<li>Your string contains invalid characters.  It can only contain letters and spaces.</li>";
          } if ($zipcodevalid == 0) {
          echo "<li>Your string contains invalid characters.  It can only contain numbers.</li>";
          }if ($securimage->check($_POST['captcha_code']) == false) {
            // the code was incorrect
            // handle the error accordingly with your other error checking
          
            // or you can do something really basic like this
            die('The code you entered was incorrect.  Go back and try again.');
          }
          
          echo "</ul>";  }
          }
          ?>
          
            rvanness;10922626 wrote:

            Ok, I have done what bradgrafelman said and the only change is the line number
            Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /hsphere/local/home/c245363/ccpsd.org/rvanness/validation/webvalidator.php on line 149

            Show us a copy of what your code looks like now that you've made the changes.

              here is the error
              Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /hsphere/local/home/c245363/ccpsd.org/rvanness/validation/webvalidator.php on line 151

              and here is the code

              <?php 
              
              session_start();
              
              
              
              include_once $_SERVER['DOCUMENT_ROOT'] . '/rvanness/validation/captcha/securimage/securimage.php';
              
              $securimage = new Securimage();
              
                $firstname = $_REQUEST['FirstName'] ;
                $lastname = $_REQUEST['LastName'] ;
                $email = $_REQUEST['Email'] ;
                $phoneday = $_REQUEST['PhoneDay'] ;
                $phoneevening = $_REQUEST['PhoneEvening'] ;
                $city = $_REQUEST['City'] ;
                $state = $_REQUEST['State'] ;
                $zipcode = $_REQUEST['ZipCode'] ;
                $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
                $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
                $aboveyes = $_REQUEST['aboveyes'] ;
                $shoppingcart = $_REQUEST['shoppingcart'] ;
                $howurgent = $_REQUEST['howurgent'] ;
                $comments = $_REQUEST['Comments'] ;
              
                function check_firstname($firstname)
               {
                if(!preg_match("/[^a-zA-Z]/",$firstname));
              	return TRUE;
                 	return FALSE;
              }
              
               function check_lastname($lastname)
               {
                if(!preg_match("/[^a-zA-Z]/",$lastname))
                return TRUE;
                else
                return FALSE;
              }
              
              function checkEmail($email) 
              {
                 if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
                 {
                    return FALSE;
                 }
              
                 list($Username, $Domain) = split("@",$email);
              
                 if(getmxrr($Domain, $MXHost)) 
                 {
                    return TRUE;
                 }
                 else 
                 {
                    if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
                    {
                       return TRUE; 
                    }
                    else 
                    {
                       return FALSE; 
                    }
                 }
              }
              function validatePhoneNoday($phoneday)
              {
                if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
                   return true;
                else
                   return false;
              }
              function validatePhoneNonight($phoneevening)
              {
                if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
                   return true;
                else
                   return false;
              }
              function check_city($city)
               {
                if(!preg_match("/[^a-zA-Z]/",$city))
                return TRUE;
                else
                return FALSE;
              }
              function check_state($state)
               {
                if(!preg_match("/[^a-zA-Z]/",$state))
                return TRUE;
                else
                return FALSE;
              }
              function validateUSAZip($zipcode)
              {
                if(preg_match("/^([0-9]{5})(-[0-9]{4})?$/i",$zipcode))
                  return true;
                else
                  return false;
              }
              function webhostvalidate($doyouneedwebhosting)
              {
              if (empty($doyouneedwebhosting)) 
              	return false;
              else
              	return true;
              	}
              	function websitebuilt($doyouneedawebsitebuilt)
              	{
              	if (empty($doyouneedawebsitebuilt)) 
              	return false;
              else
              	return true;
              	}
              	function beforeyes($aboveyes)
              	{
              	if (empty($aboveyes)) 
              	return false;
              else
              	return true;
              	}
              	function shoppingcart($shoppingcart)
              		{
              	if (empty($shoppingcart)) 
              	return false;
              else
              	return true;
              	}
              	function urgent($howurgent)
              		{
              	if (empty($howurgent)) 
              	return false;
              else
              	return true;
              	}
              	function comments($comments)
              		{
              	if (empty($comments)) 
              	return false;
              else
              	return true;
              	}
              	/* Validation */
              
              $error=0; // check up variable
              
              /* get it checking */
              
              if(!check_firstname($firstname))
              {
                echo &#8220;Sorry, Non valid input /$firstname/ in FirstName&#8221;;
                $error++; // $error=$error+1;
              }
              if(!check_lastname($lastname));
              {
                echo &#8220;Illegal input /$lastname/ in &#8216;Last Name&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(checkEmail($email) == FALSE) 
              {
                 echo "E-mail entered is not valid.";
                 $error++; // $error=$error+1;
              } 
              if(!validatePhoneNoday($phoneday))
              {
                echo &#8220;Illegal input /$phoneday/ in &#8216;Phone Day&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!validatePhoneNonight($phoneevening))
              {
                echo &#8220;Illegal input /$phoneevening/ in &#8216;Phone evening&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!check_city($city))
              {
                echo &#8220;Illegal input /$city/ in &#8216;City&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!check_state($state))
              {
                echo &#8220;Illegal input /$state/ in &#8216;State&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!validateUSAZip($zipcode))
              {
                echo &#8220;Illegal input /$zipcode/ in &#8216;ZipCode&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!webhostvalidate($doyouneedwebhosting))
              {
                echo &#8220;Illegal input /$doyouneedwebhosting/ in Do you need web hosting&#8221;;
                $error++; // $error=$error+1;
              }
              if(!websitebuilt($doyouneedawebsitebuilt))
              {
                echo &#8220;Illegal input /$doyouneedawebsitebuilt/ in &#8216;Do you need a website built&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!beforeyes($aboveyes))
              {
                echo &#8220;Illegal input /$aboveyes/ in &#8216;If you answered yes to the above question do you know what the page should look like?&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!shoppingcart($shoppingcart))
              {
                echo &#8220;Illegal input /$shoppingcart/ in &#8216;Is this site going to have a shopping cart?&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if(!urgent($howurgent))
              {
                echo &#8220;Illegal input /$howurgent/ in &#8216;How urgent is this to you?&#8221;;
                $error++; // $error=$error+1;
              }
              if(!comments($comments))
              {
                echo &#8220;Illegal input /$comments/ in &#8216;Comments&#8217;&#8221;;
                $error++; // $error=$error+1;
              }
              if ($securimage->check($_POST['captcha_code']) == false) {
                // the code was incorrect
                // handle the error accordingly with your other error checking
              
                // or you can do something really basic like this
                die('The code you entered was incorrect.  Go back and try again.');
                $error++; // $error=$error+1;
              }
              if($error == 0)
              {
              //send email
              $to      = 'rvannessweb@live.com';
              $subject = 'webform';
                $name = $_REQUEST['FirstName'] ;
                $name .= $_REQUEST['LastName'] ;
                $email = $_REQUEST['Email'] ;
                $phoneday = $_REQUEST['PhoneDay'] ;
              $phoneevening = $_REQUEST['PhoneEvening'] ;
                $city = $_REQUEST['City'] ;
                $state = $_REQUEST['State'] ;
                $zipcode = $_REQUEST['ZipCode'] ;
                $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
                $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
                $aboveyes = $_REQUEST['aboveyes'] ;
                $shoppingcart = $_REQUEST['shoppingcart'] ;
                $howurgent = $_REQUEST['howurgent'] ;
              $comments = $_REQUEST['Comments'] ;
                 $eol="\r\n"; // *****Try setting this one to \n if the \r\n does not send the mail *****
                 $headers = 'From: Web form <rvannessweb@gmail.com>'.$eol;
              $headers .= 'Reply-To: Web form <rvannessweb@gmail.com>'.$eol;
              $headers .= 'Return-Path: Web form <rvannessweb@gmail.com>'.$eol;     // this one and the above to set reply address
              $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; // This creates a unique message ID
              $headers .= "X-Mailer: PHP v".phpversion().$eol;           // This and the above help avoid spam-filters
              
               //The message
              $msg = "A web quote has been submitted.\n" .
              	"Name: $name\n" .
              	"Email: $email\n" .
              	"Day time phone number: $phoneday\n" .
              	"Night time phone number: $phoneevening\n" .
              	"City: $city\n" .
              	"State: $state\n" .
              	"Zipcode: $zipcode\n" .
              	"Do you need web hosting?: $doyouneedwebhosting\n" .
              	"Do you need a web site built: $doyouneedawebsitebuilt\n" .
              	"If you answered yes to the above question do you know what the page should look like?: $aboveyes\n" .
              	"Is this site going to have a shopping cart?: $shoppingcart\n" .
              	"How urgent is this to you?: $howurgent\n" .
              	"Your comment: $comments";
              
               if(mail( $to, $subject, $msg, $headers))
              //Redirect
                header("Location: http://ccpsd.org/rvanness/");
              /* Make sure that code below does not get executed when we redirect. */
              exit;
              
              }
              else{
                echo &#8220;Number of errors: $error&#8221;;
              }
              ?>
              

              thanks for all you help and time. it is greatly appreciated

                You still have the curly quote issue. For example, this is line 151:

                echo “Sorry, Non valid input /$firstname/ in FirstName”;

                vs. what it should be:

                echo "Sorry, Non valid input /$firstname/ in FirstName";

                As you can see from visual inspection of both the code as well as the syntax highlighting, the string delimiters are double quotes which will cause a parse error.

                What editor were you using that inserted those, anyway??

                  OK so then so if i am correct what your saying is it would be best to remove all the {} brackets correct? Also i use notepad++ using PHP language. So what you are saying is that i should change the code form this

                  if(!check_firstname($firstname))
                  {
                    echo &#8220;Sorry, Non valid input /$firstname/ in FirstName&#8221;;
                    $error++; // $error=$error+1;
                  }
                  

                  to this

                  if(!check_firstname($firstname))
                  
                    echo &#8220;Sorry, Non valid input /$firstname/ in FirstName&#8221;;
                    $error++; // $error=$error+1;
                  
                  

                  correct.
                  Also i emailed my teacher and he said the reason he had u use those is because it made it easy for him to check the code.
                  thanks for all your time and help bradgrafelman

                    rvanness wrote:

                    OK so then so if i am correct what your saying is it would be best to remove all the {} brackets correct?

                    No, the braces are not a problem, and in fact removing them can change the meaning of your code, which happens in your example. ($error++; would then happen unconditionally.) The braces that you should remove are the unnecessary braces that surround pretty much your entire script.

                    The problem is that you are using the wrong quote characters. Notepad++ should not have this problem. What might cause this problem is if your teacher gave you an example in some document (e.g., Microsoft Word format), and that example used those quote characters. If you copied and pasted the code from that document into your PHP script, those characters may well remain as-is. You would then need to change those quote characters into "normal" single or double quote characters.

                      could you please explain what quotes i need to remove. in notepad ++ if it is in "" it is gray by what bradgrafelman said it is supposed to be red. i have dreamweaver but i don't like to use it should i try using to fix this file?

                        could you please explain what you mean about the "". also in notepad++ if it has"" around it it is gray by what bradgrafelman said it is supposed to be red. I have dreamweaver but i don't like to use it, but should i use it to fix the file?

                          rvanness wrote:

                          could you please explain what quotes i need to remove.

                          You need to replace &#8220; and &#8221; with " or ' (i.e., replace the problematic quotes with ASCII double or single quote characters).

                          rvanness wrote:

                          in notepad ++ if it is in "" it is gray by what bradgrafelman said it is supposed to be red.

                          bradgrafelman was talking about this message board's PHP code syntax highlighting colour scheme. A quick check shows that Notepad++ does colour PHP strings grey. With those problematic quotes instead, it leaves them in the default font colour.

                          rvanness wrote:

                          i have dreamweaver but i don't like to use it should i try using to fix this file?

                          Notepad++ is good enough for this job.

                            You can also copy over your code into a post here on the board and enclose it in
                            [php ] [/php ] tags (without the extra space I inserted here), then you get the red and blue highlighting that you see in brad's post...(and as an extra-benefit we can have another look 😉)

                              <?php 
                              
                              session_start();
                              
                              
                              
                              include_once $_SERVER['DOCUMENT_ROOT'] . '/rvanness/validation/captcha/securimage/securimage.php';
                              
                              $securimage = new Securimage();
                              
                                $firstname = $_REQUEST['FirstName'] ;
                                $lastname = $_REQUEST['LastName'] ;
                                $email = $_REQUEST['Email'] ;
                                $phoneday = $_REQUEST['PhoneDay'] ;
                                $phoneevening = $_REQUEST['PhoneEvening'] ;
                                $city = $_REQUEST['City'] ;
                                $state = $_REQUEST['State'] ;
                                $zipcode = $_REQUEST['ZipCode'] ;
                                $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
                                $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
                                $aboveyes = $_REQUEST['aboveyes'] ;
                                $shoppingcart = $_REQUEST['shoppingcart'] ;
                                $howurgent = $_REQUEST['howurgent'] ;
                                $comments = $_REQUEST['Comments'] ;
                              
                                function check_firstname($firstname)
                               {
                                if(!preg_match("/[^a-zA-Z]/",$firstname));
                              	return TRUE;
                                 	return FALSE;
                              }
                              
                               function check_lastname($lastname)
                               {
                                if(!preg_match("/[^a-zA-Z]/",$lastname))
                                return TRUE;
                                else
                                return FALSE;
                              }
                              
                              function checkEmail($email) 
                              {
                                 if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
                                 {
                                    return FALSE;
                                 }
                              
                                 list($Username, $Domain) = split("@",$email);
                              
                                 if(getmxrr($Domain, $MXHost)) 
                                 {
                                    return TRUE;
                                 }
                                 else 
                                 {
                                    if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
                                    {
                                       return TRUE; 
                                    }
                                    else 
                                    {
                                       return FALSE; 
                                    }
                                 }
                              }
                              function validatePhoneNoday($phoneday)
                              {
                                if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
                                   return true;
                                else
                                   return false;
                              }
                              function validatePhoneNonight($phoneevening)
                              {
                                if(ereg('^[2-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}$', $phone))
                                   return true;
                                else
                                   return false;
                              }
                              function check_city($city)
                               {
                                if(!preg_match("/[^a-zA-Z]/",$city))
                                return TRUE;
                                else
                                return FALSE;
                              }
                              function check_state($state)
                               {
                                if(!preg_match("/[^a-zA-Z]/",$state))
                                return TRUE;
                                else
                                return FALSE;
                              }
                              function validateUSAZip($zipcode)
                              {
                                if(preg_match("/^([0-9]{5})(-[0-9]{4})?$/i",$zipcode))
                                  return true;
                                else
                                  return false;
                              }
                              function webhostvalidate($doyouneedwebhosting)
                              {
                              if (empty($doyouneedwebhosting)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	function websitebuilt($doyouneedawebsitebuilt)
                              	{
                              	if (empty($doyouneedawebsitebuilt)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	function beforeyes($aboveyes)
                              	{
                              	if (empty($aboveyes)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	function shoppingcart($shoppingcart)
                              		{
                              	if (empty($shoppingcart)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	function urgent($howurgent)
                              		{
                              	if (empty($howurgent)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	function comments($comments)
                              		{
                              	if (empty($comments)) 
                              	return false;
                              else
                              	return true;
                              	}
                              	/* Validation */
                              
                              $error=0; // check up variable
                              
                              /* get it checking */
                              
                              if(!check_firstname($firstname))
                              
                                echo "Sorry, Non valid input /$firstname/ in FirstName";
                                $error++; // $error=$error+1;
                              
                              if(!check_lastname($lastname));
                              {
                                echo "Illegal input /$lastname/ in Last Name";
                                $error++; // $error=$error+1;
                              }
                              if(checkEmail($email) == FALSE) 
                              {
                                 echo "E-mail entered is not valid.";
                                 $error++; // $error=$error+1;
                              } 
                              if(!validatePhoneNoday($phoneday))
                              {
                                echo "Illegal input /$phoneday/ in Phone Day";
                                $error++; // $error=$error+1;
                              }
                              if(!validatePhoneNonight($phoneevening))
                              {
                                echo "Illegal input /$phoneevening/ in Phone evening";
                                $error++; // $error=$error+1;
                              }
                              if(!check_city($city))
                              {
                                echo "Illegal input /$city/ in City";
                                $error++; // $error=$error+1;
                              }
                              if(!check_state($state))
                              {
                                echo "Illegal input /$state/ in State";
                                $error++; // $error=$error+1;
                              }
                              if(!validateUSAZip($zipcode))
                              {
                                echo "Illegal input /$zipcode/ in ZipCode";
                                $error++; // $error=$error+1;
                              }
                              if(!webhostvalidate($doyouneedwebhosting))
                              {
                                echo "Illegal input /$doyouneedwebhosting/ in Do you need web hosting";
                                $error++; // $error=$error+1;
                              }
                              if(!websitebuilt($doyouneedawebsitebuilt))
                              {
                                echo "Illegal input /$doyouneedawebsitebuilt/ in do you need a website built";
                                $error++; // $error=$error+1;
                              }
                              if(!beforeyes($aboveyes))
                              {
                                echo "Illegal input /$aboveyes/ in If you answered yes to the above question do you know what the page should look like?";
                                $error++; // $error=$error+1;
                              }
                              if(!shoppingcart($shoppingcart))
                              {
                                echo "Illegal input /$shoppingcart/ in Is this site going to have a shopping cart?";
                                $error++; // $error=$error+1;
                              }
                              if(!urgent($howurgent))
                              {
                                echo "Illegal input /$howurgent/ in How urgent is this to you?";
                                $error++; // $error=$error+1;
                              }
                              if(!comments($comments))
                              {
                                echo "Illegal input /$comments/ in Comments";
                                $error++; // $error=$error+1;
                              }
                              if ($securimage->check($_POST['captcha_code']) == false) {
                                // the code was incorrect
                                // handle the error accordingly with your other error checking
                              
                                // or you can do something really basic like this
                                die('The code you entered was incorrect.  Go back and try again.');
                                $error++; // $error=$error+1;
                              }
                              if($error == 0)
                              {
                              //send email
                              $to      = 'rvannessweb@live.com';
                              $subject = 'webform';
                                $name = $_REQUEST['FirstName'] ;
                                $name .= $_REQUEST['LastName'] ;
                                $email = $_REQUEST['Email'] ;
                                $phoneday = $_REQUEST['PhoneDay'] ;
                              $phoneevening = $_REQUEST['PhoneEvening'] ;
                                $city = $_REQUEST['City'] ;
                                $state = $_REQUEST['State'] ;
                                $zipcode = $_REQUEST['ZipCode'] ;
                                $doyouneedwebhosting = $_REQUEST['doyouneedwebhosting'] ;
                                $doyouneedawebsitebuilt = $_REQUEST['doyouneedawebsitebuilt'] ;
                                $aboveyes = $_REQUEST['aboveyes'] ;
                                $shoppingcart = $_REQUEST['shoppingcart'] ;
                                $howurgent = $_REQUEST['howurgent'] ;
                              $comments = $_REQUEST['Comments'] ;
                                 $eol="\r\n"; // *****Try setting this one to \n if the \r\n does not send the mail *****
                                 $headers = 'From: Web form <rvannessweb@gmail.com>'.$eol;
                              $headers .= 'Reply-To: Web form <rvannessweb@gmail.com>'.$eol;
                              $headers .= 'Return-Path: Web form <rvannessweb@gmail.com>'.$eol;     // this one and the above to set reply address
                              $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; // This creates a unique message ID
                              $headers .= "X-Mailer: PHP v".phpversion().$eol;           // This and the above help avoid spam-filters
                              
                               //The message
                              $msg = "A web quote has been submitted.\n" .
                              	"Name: $name\n" .
                              	"Email: $email\n" .
                              	"Day time phone number: $phoneday\n" .
                              	"Night time phone number: $phoneevening\n" .
                              	"City: $city\n" .
                              	"State: $state\n" .
                              	"Zipcode: $zipcode\n" .
                              	"Do you need web hosting?: $doyouneedwebhosting\n" .
                              	"Do you need a web site built: $doyouneedawebsitebuilt\n" .
                              	"If you answered yes to the above question do you know what the page should look like?: $aboveyes\n" .
                              	"Is this site going to have a shopping cart?: $shoppingcart\n" .
                              	"How urgent is this to you?: $howurgent\n" .
                              	"Your comment: $comments";
                              
                               if(mail( $to, $subject, $msg, $headers))
                              //Redirect
                                header("Location: http://ccpsd.org/rvanness/");
                              /* Make sure that code below does not get executed when we redirect. */
                              exit;
                              
                              }
                              else{
                                echo "Number of errors: $error";
                              }
                              ?>
                              

                                Thanks every body that fixed it. now i know if that message comes up again to change "" to ' ' thanks agian

                                  No problem 🙂
                                  Remember to mark this thread as resolved using the thread tools.

                                    Ok now i have another problem anything i enter in the last name field comes back false. does anybody know a fix for that?

                                    function check_lastname($lastname)
                                     {
                                      if(!preg_match("/[^a-zA-Z]/",$lastname))
                                      return TRUE;
                                      else
                                      return FALSE;
                                    }
                                    

                                      It looks okay, but I would write it as:

                                      <?php
                                      function is_valid_lastname($lastname)
                                      {
                                          return ctype_alpha($lastname);
                                      }
                                      
                                      echo 'rvanness is ' . (is_valid_lastname('rvanness') ? 'valid' : 'invalid');
                                      ?>
                                        Write a Reply...