我的網站有一個簡單的PHP支持的聯繫表單,當用戶點擊發送時,返回頁面結果。我想修改它以將它們轉發到一個擁有感謝頁面的URL。任何人都可以指出我的基本代碼行嗎?我send.php
的內容在這裏:可以將一個聯繫表單完成者轉發到另一個URL嗎?
define("WEBMASTER_EMAIL", '[email protected]');
error_reporting (E_ALL^E_NOTICE);
function ValidateEmail($email) {
$regex = '/([a-z0-9_.-]+)'. # name
'@'. # at
'([a-z0-9.-]+){2,255}'. # domain & possibly subdomains
'.'. # period
'([a-z]+){2,10}/i'; # domain extension
if($email == '') {
return false;
} else {
$eregi = preg_replace($regex, '', $email);
}
return empty($eregi) ? true : false;
}
$post = (!empty($_POST)) ? true : false;
if($post) {
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$message = stripslashes($_POST['message']);
$error = '';
// Check name
if(!$name) {
$error .= 'Name required! ';
}
// Check email
if(!$email) {
$error .= 'E-mail required! ';
}
if($email && !ValidateEmail($email)) {
$error .= 'E-mail address is not valid! ';
}
// Check message
if(!$message) {
$error .= "Please enter your message!";
}
if(!$error) {
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail) {
echo 'OK';
}
} else {
echo '<div class="errormsg">'.$error.'</div>';
}
}
更換回聲「OK」;與標題('位置:...')或元刷新? – Jared 2012-01-28 14:04:12