我有一个单一的网页组合网站,我正在建设,我有一个联系表格,我需要使用PHP发送脚本来处理。当谈到PHP时我是新手,所以我很难让这个工作。我已经做了一些搜索,但我找不到我在找什么。需要一个PHP电子邮件发送HTML格式脚本
这是我所做的,我从我建立的PHP联系页面复制了这个,但PHP和表单在同一页上,我需要一个外部send.php来处理我的表单。
<?php
$error = ''; // error message
$name = ''; // sender's name
$email = ''; // sender's email address
$company = ''; // company name
$subject = ''; // subject
$comment = ''; // the message itself
if(isset($_POST['send']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$subject = $_POST['subject'];
$comment = $_POST['comment'];
if($error == '')
{
if(get_magic_quotes_gpc())
{
$message = stripslashes($message);
}
// the email will be sent here
// make sure to change this to be your e-mail
$to = "[email protected]";
// the email subject
// '[Contact Form] :' will appear automatically in the subject.
// You can change it as you want
$subject = '[Contact Form] : ' . $subject;
// the mail message (add any additional information if you want)
$msg = "From : $name \r\ne-Mail : $email \r\nCompany : $company \r\nSubject : $subject \r\n\n" . "Message : \r\n$message";
mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
}
}
if(!isset($_POST['send']) || $error != '')
{
header("location: http://www.#.com/#contact");
}
?>
所以对我的形式我想有:
<form method="post" action="send.php" class="form">
我打算使用HTML5和jQuery验证表单,所以我真的只需要脚本来捕获信息并发送电子邮件到一个地址。发送后,我希望脚本重定向回联系页面。
编辑:
我发现谷歌花了一段时间后的解决方案。 http://www.website.com/#contact“);? >
在问这个问题之前,你显然没有看过与此相关的数百个其他问题。 – 2012-03-15 19:29:52