表格提交后如何重定向?

时间:2017-04-14 11:20:20

标签: php forms redirect

目前我的编码对PHP执行post命令,将数据推送到电子邮件。 我希望找到一种方法,在服务器将电子邮件发送到URL之后重定向。

<?php
$email_from = 'my@e-mail.co.uk';
$email_subject = "New Form submission";
$email_body = "You have received a new insurance enquiry from $firstname $lastname $gender born on $dobday $dobmonth $dobyear $smoker is after $insurtype
They want to cover $cover,000 for $years years for $meandpartner

Contact information:
Mobile: $mobile
Telephone: $landline
E-mail: $email
Street: $street
City: $city
Postcode: $postcode

Partner details:
$pfirstname
$plastname
$pgender
$pdobday $pdobmonth $pdobyear
$psmoker

" ?>

<?php
$to = "my@email.co.uk";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: my@email.co.uk";
mail($to,$email_subject,$email_body,$headers);
?>

2 个答案:

答案 0 :(得分:0)

您可以使用标题:

header('Location: mypage.php');

此处有更多信息:http://php.net/manual/en/function.header.php

答案 1 :(得分:0)

submitform = name of form

if (isset($_POST['submitform']))
 {?>
  <script type="text/javascript">
   window.location = "http://www.google.com/";
  </script>
<?php }