0

我无法从此电子邮件表单中获取 POST 变量。

有什么建议么?

html文件中的表单部分:

<form id="form_28" name="register" onsubmit="return validate_form_28(this)" action="sendmail.php" method="post" target="_blank" enctype="text/plain" style="margin:0;position:absolute;left:67px;top:297px;width:576px;height:291px;">
<input type="text" id="edit_23" name="email" value="" style="position:absolute; left:290px; top:93px; width:209px;">
</form>

sendmail.php 文件

<?php
$email = $_POST['email'] ;


$email_body =  "Here is the message";
mail( "mymail@mysite.com", "title", $email_body, "From: $email" );
print "Congratulations your email has been sent";

?>

validate_form_28 :

function validate_form_28( form )
{
    if( ltrim(rtrim(form.elements['email'].value,' '),' ')=="" ) { alert("you have to fill it"); form.elements['email'].focus(); return false; }
    if(!ValidateEmail(form.elements['email'].value)) { alert("not valid emailv"); form.elements['email'].focus(); return false; }
    return true;
}
4

3 回答 3

3

关闭您的表格。

</form>

并改变:

mail( "mymail@mysite.com", "title", $email_body, "From: $email" );

mail( "mymail@mysite.com", "title", $email_body, "From: " . $email );
于 2013-09-12T13:35:42.607 回答
0

您好,请删除enctype="text/plain"

text/plain = 空格转换为“+”符号,但不编码特殊字符

于 2013-09-12T13:42:23.797 回答
0

我玩了一下 php 并且enctype="text/plain"不兼容,把它拿出来,它应该可以工作:

来自另一个答案的参考

于 2013-09-12T13:43:53.873 回答