我有一個單一的網頁組合網站,我正在建設,我有一個聯繫表格,我需要使用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