1

以下代码在第 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: "$email_form""; 为变量 $email_form 加上单引号,它会运行并且不会抛出异常。但是,它会发送一封电子邮件,上面写着“电子邮件:''”,例如,它将 $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>

谢谢您的帮助

4

2 回答 2

4

改变:

$email_message = "Email: "$email_form"";

至:

$email_message = "Email: " . $email_form . "";

你忘了连接。

于 2012-09-05T21:54:36.860 回答
1

改变

$email_message = "Email: "$email_form"";

$email_message = "Email: " . $email_form . "";

此外,您似乎缺少分号:

//Create email headers
$headers = 'From: '.$email_form."\r\n". <---
于 2012-09-05T21:56:54.033 回答