我已经阅读了所有以前关于在成功提交php表单后重定向到另一个url的问题,但我自己也遇到了这个问题,并且非常感谢你能给我的任何帮助!
<?php
require_once("included_functions.php");
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action']))):
$name = $_POST['name'];
$email = $_POST['email'];
$fictioninterest = $_POST['fictioninterest'];
$bookclub = $_POST['bookclub'];
$newsletter = $_POST['blogtalk'];
$blogtalk = $_POST['blogtalk'];
$skype = $_POST['skype'];
$comments = $_POST['comments'];
$formerrors = false;
if ($name === '') :
$err_name = '<div class="error">Sorry, your name is a required field</div>';
endif; // input field empty
if ($email === '') :
$err_email = '<div class="error">Sorry, your email is a required field</div>';
endif; // input field empty
if (isset($_POST['comments'])) {
$comments = filter_var($_POST['comments'], FILTER_SANITIZE_STRING );
}
$formdata = array (
'name' => $name,
'email' => $email,
'fictioninterest' => $fictioninterest,
'bookclub' => $bookclub,
'newsletter' => $newsletter,
'blogtalk' => $blogtalk,
'skype' => $skype
);
if (!($formerrors)) :
$to = "bookclub@literaryfictionreview.com";
$subject = "From $name -- Signup Page";
$message = json_encode($formdata);
$replyto = "From: bookclub@literaryfictionreview.com \r\n".
"Reply-To: bookclub@literaryfictionreview.com \r\n";
if (mail($to, $subject, $message)):
$msg = "";
redirect_to("confirmation.html");
else:
$msg = "Problem sending the message";
endif; // mail form data
endif; // check for form errors
endif; //form submitted
?>
我需要取出$ msg =&#34;&#34 ;;线?并删除下面的$ msg行返回&#34;问题发送消息&#34 ;; ?我需要输入标题标记吗?
非常感谢你对此的帮助!
答案 0 :(得分:1)
通过PHP header()
功能发送HTTP“location”标头(http://en.wikipedia.org/wiki/HTTP_location),例如header("Location: /foo.php");
您可能还希望随后exit()
脚本,以便不会执行if
条件下的操作。