php - Contact Form Keeps Getting Errors -


this question has answer here:

i working on adding security onto contact form , can't seem find reason why errors. currently, when test php form, error: parse error: syntax error, unexpected t_if in /home/content/86/5284386/html/websitenamewashere/contact.php on line 16

php:

    <?php   if(isset($_post['email'])) {               // edit 2 lines below required       $to = "yahoo@gmail.com";       $subject = "contact form submission";          function died($error) {           // error code can go here           echo "we sorry, there error(s) found form submitted. ";           echo "these errors appear below.<br /><br />";           echo $error."<br /><br />";           echo "please go , fix these errors.<br /><br />";           die();       }               // validation expected data exists       if(!isset($_post['contact-name']) ||            !isset($_post['contact-email']) ||           !isset($_post['contact-phone']) ||           !isset($_post['child_info'])) {           died('we sorry, there appears problem form submitted.');              }                   $contactname = $_post["contact-name"]; //required          $contactemail = $_post["contact-email"]; //required          $contactphone = $_post["contact-phone"]; //required          $child_info = $_post["child_info"]; //required                $error_message = "";       $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/';     if(!preg_match($email_exp,$contactemail)) {       $error_message .= 'the email address entered not appear valid.<br />';     }       $string_exp = "/^[a-za-z .'-]+$/";     $numb_exp = '/^[0-9.-]';     if(!preg_match($string_exp,$contactname)) {       $error_message .= 'the first name entered not appear valid.<br />';     }     if(!preg_match($numb_exp,$contactphone)) {       $error_message .= 'the phone number entered not appear valid.<br />';     }     if(strlen(child_info) < 2) {       $error_message .= 'the comments entered not appear valid.<br />';     }     if(strlen($error_message) > 0) {       died($error_message);     }       $email_message = "form details below.\n\n";               function clean_string($string) {         $bad = array("content-type","bcc:","to:","cc:","href");         return str_replace($bad,"",$string);       }               $email_message .= "first name: ".clean_string($contactname)."\n";        $email_message .= "email: ".clean_string($contactemail)."\n";       $email_message .= "telephone: ".clean_string($contactphone)."\n";       $email_message .= "child information: ".clean_string($child_info)."\n";                   // create email headers   $headers = 'from: '.$contactemail."\r\n".   'reply-to: '.$contactemail."\r\n" .   'x-mailer: php/' . phpversion();   @mail($email_to, $email_subject, $email_message, $headers);     ?>       thank contacting us. in touch soon.       <?php   }   ?> 

my html:

<form action="contact.php" class="footer-form" method="post"> <p class="title">how can of service?</p>  <div class="form-group">     <strong>         <input type="text" class="form-control" name="contact-name" id="contact-name" placeholder="name:">     </strong> </div> <div class="form-group">     <strong>         <input type="email" class="form-control" name="contact-email"" id="contact-email" placeholder="e-mail:">     </strong> </div> <div class="form-group">     <strong>         <input type="phone" class="form-control" name="contact-phone" id="contact-phone" placeholder="phone:">     </strong> </div> <div class="form-group">     <strong>          <input type="text" class="form-control" name="child_info" id="child_info" placeholder="tell child:">     </strong> </div> <button type="submit" class="btn btn-default waves-effect waves-button waves-float waves-classic"><strong>submit</strong></button> 

you've missed closing speech quotations on following line:

$subject = "contact form submission; 

it should be:

$subject = "contact form submission"; 

in html have speech quote (not affect php error)

 name="contact-email"" 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -