[英]I am getting an error with a PHP mail script
I am trying to setup a contact box on my website, I thought I had done this right but it seems not. 我试图在我的网站上设置一个联系人框,我以为我做对了,但似乎没有。
?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "contact@jozhhdesigns.com
<script>
type = "text/javascript" >
/* <![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 = "JozhhDesigns You have been contacted!";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
Then, The Error I Get Is: 然后,我得到的错误是:
unexpected T_STRING in your code on line 7
第7行的代码中出现意外的T_STRING
Anyone know what is going wrong here? 有人知道这里出了什么问题吗?
After looking through the comments, I changed some things, and now I have the following 浏览完评论后,我做了一些更改,现在我有以下内容
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = 'contact@jozhhdesigns.com';
<script type='text/javascript'>
/* <![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 = 'JozhhFX You have been contacted!';
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
With this I have removed the double (") and replaced them with single (') It is now giving me the error 为此,我删除了双精度(“)并将其替换为单精度('),这给了我错误
"syntax error, unexpected '<' in /public_html/sendmail.php on line 6"
I know I am bad at this but any help with it? 我知道我对此很不好,但是有什么帮助吗?
change 更改
$recipient = "contact@jozhhdesigns.com
<script>
type="text/javascript">
/* <![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>";
to 至
$recipient = "contact@jozhhdesigns.com";
<script type="text/javascript">
/* <![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>
You close the opening script tag with the type declaration outside it. 关闭打开的脚本标签,并在其外部进行类型声明。
<script <-- Here
type="text/javascript">
$recipient should be just email, Try this: $ recipient应该只是电子邮件,请尝试以下操作:
$recipient = "contact@jozhhdesigns.com";
Here is documentation about mail function in php: http://php.net/manual/en/function.mail.php 这是有关php中邮件功能的文档: http : //php.net/manual/zh/function.mail.php
Your $recipient has values with double quotes! 您的$收件人具有双引号的值!
Try something like 尝试类似
$recipient = "contact@jozhhdesigns.com";
$script = <<<CDATA
<script>
type="text/javascript">
/* <![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>
CDATA;
Use single quotes instead of double quotes here type="text/javascript"> and here document.getElementsByTagName("script"); 在此处type =“ text / javascript”>和document.getElementsByTagName(“ script”);处使用单引号而不是双引号。
It will be somewhat like this type='text/javascript'> and document.getElementsByTagName('script'); 有点像这种type ='text / javascript'>和document.getElementsByTagName('script');
Please check this link https://stackoverflow.com/questions/20072751/write-the-email-code-for-upload-resume-in-contact-page-receive-the-email-in-php/20073275#20073275 请检查此链接https://stackoverflow.com/questions/20072751/write-the-email-code-for-upload-resume-in-contact-page-receive-the-email-in-php/20073275#20073275
There is some closing tag and double qoutes issue please try this 有一些结束标签和双重qoutes问题,请尝试此操作
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "contact@jozhhdesigns.com";
$subject = "JozhhDesigns You have been contacted!";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.