以下代码在第10行中抛出T变量异常
//Two Email Lines
$email_to = "contact@website.com";
$email_subject = "AUTO: WEB BETA INVITE REQUEST";
//Set equal to email form textbox
$email_form = $_POST["email_text"];
$email_message = "Email: "$email_form"";
//Create email headers
$headers = 'From: '.$email_form."\r\n".
@mail($email_to, $email_subject,$email_message,$headers);
当我更改=“电子邮件:”$ email_form“”;在变量$ email_form周围单引号,它运行并抛出没有异常。但是,它会发送一封电子邮件,上面写着“Email:''”,因为它会将$ email_form变量读为空白,而不是。
表格的HTML代码如下。
<form method="post" action="Email_Form_Script.php" enctype="text/plain" onsubmit="window.open('FormPopUp.html','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');" >
<div><input type="text" class="text" name="email_text" id="emailForm" value="Enter your e-mail address" onfocus="if(this.value=='Enter your e-mail address') { this.value = '' }" onblur="if(this.value=='') { this.value = 'Enter your e-mail address' }" /><input type="hidden" value="" name="email2"/><input type="hidden" name="loc" value="en_US"/><input type="submit" class="submit" value=""
/></div></form>
感谢您的帮助
答案 0 :(得分:4)
变化:
$email_message = "Email: "$email_form"";
为:
$email_message = "Email: " . $email_form . "";
你忘了连接了。
答案 1 :(得分:1)
更改
$email_message = "Email: "$email_form"";
到
$email_message = "Email: " . $email_form . "";
看起来你错过了一个分号:
//Create email headers
$headers = 'From: '.$email_form."\r\n". <---