Could someone please take a look at my code and let me know what might be wrong? I get the following error when trying to send an e-mail from the contact form on my website: Parse error: syntax error, unexpected 'var' (T_VAR) in /homepages/13/d277856023/htdocs/mail.php on line 11

<?php 
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mail_to ='example@example.com';

$subject = 'Message from a site visitor ' . $field_name;
$formcontent="From: $name \n Message: $message";
$recipient = "example@example.com";
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();/* ]]> */</script>";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#39454b;'> Return Home</a>";
?>

    You've got some random Javascript appearing in the PHP code on line 11. Remove that Javascript code (or move it to wherever it's actually supposed to be) and you'll have no other parse errors.

      Thank you! Can you tell me what specifically looks like random Javascript? I don't know much about it at all.

        Nevermind. I just completely deleted line 11 and it's working now!

          Write a Reply...