PHP 联系表单编辑
我不是 PHP 专业人士,刚刚开始,想知道您是否可以帮助我。
我正在尝试获取此联系表格,然后通过电子邮件向我说明姓名和类似的消息。
姓名: 弗雷德·博客 消息:消息,消息。
但是当我尝试时,我得到的只是消息,我似乎无法在任何地方插入名称变量。
这是代码
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$subject = $_REQUEST['subject'] ;
mail( "[email protected]", "Name: $name", "$subject", $message, "From: $email" );
header( "Location:contact.php" );
?>
Im not a pro at PHP, just starting actually and was wondering if you could help me.
Im trying to get this contact form to email me stating the Persons Name and the message like this.
Name: Fred Blogs
Message: Message, Message.
But when I try all I get is the message, I cant seem to insert the name variable anywhere.
This is the code
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$subject = $_REQUEST['subject'] ;
mail( "[email protected]", "Name: $name", "$subject", $message, "From: $email" );
header( "Location:contact.php" );
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的参数有点混乱:
此外,您不应该在不验证电子邮件地址的情况下执行
"From: $email"
- 这将使您的脚本处于发送垃圾邮件的状态。You've got the arguments mixed up a little:
Additionally you shouldn't do
"From: $email"
without validating the email address - this will leave your script open to sending out spam.您向
mail()
函数。尝试这样的事情:You are passing too many parameters to the
mail()
function. Try something like this:看一下 mail() 的手册:
但无论如何,我强烈建议您不要依赖 PHP 的 mail() 函数,因为它的返回值并不表明邮件是否确实已发送。使用 phpmailer 进行邮件发送。
最美好的祝愿,
法比安
Take a look at the manual for mail():
But anyways, I strongly suggest you don't rely on PHP's mail()-function as its return value does not indicate if a mail really has been sent. Use phpmailer for mailing instead.
Best wishes,
Fabian