如何重定向到 thankyou.html 页面 (PHP)
How to redirect to thankyou.html page (PHP)
我试图在邮件发送后重定向到 thankyou.html,但我没有成功。
我使用了 header 选项,但它不适合我。
可能是我做错了什么。
当有人提交此查询时,页面应该转到 thankyou.html,我已经制作了此页面。
这是我的php脚本
<?php
include("connect.php");
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$treatment = $_POST['treatment'];
$gender = $_POST['gender'];
$date = date('y/m/d');
$message = $_POST['message'];
$to = 'enquiry@kbc.com' ;
$subject = 'Inquiry' ;
$query = "insert into inquiry
(name,email,phone,treatment,gender,date) values ('$name','$email','$phone','$treatment','$gender','$date')";
if(mysqli_query($db_conx, $query)){
echo "<script>alert('Thank you for submitting your query, our doctors will call you soon!')</script>";
}
mail ( $to, $subject,
"From:" . $name .
", Email: " . $email .
", Number: ". $phone .
", Gender: " . $gender.
", Treatment: " . $treatment.
", Message: " . $message );
}
?>
尝试使用 header('Location: http://xxxxxxxx')
参考:http://php.net/manual/en/function.header.php
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>
这里有两个选择,
1) 你可以使用:
header('Location: http://domain.com/thank-you.html');
2) 使用javascript:
window.location.href='http://domain.com/thankyou.html';
此外,
您可以通过 Ajax post 您的邮件数据,如果数据成功 posted,您可以重定向 :)
我试图在邮件发送后重定向到 thankyou.html,但我没有成功。
我使用了 header 选项,但它不适合我。 可能是我做错了什么。 当有人提交此查询时,页面应该转到 thankyou.html,我已经制作了此页面。
这是我的php脚本
<?php
include("connect.php");
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$treatment = $_POST['treatment'];
$gender = $_POST['gender'];
$date = date('y/m/d');
$message = $_POST['message'];
$to = 'enquiry@kbc.com' ;
$subject = 'Inquiry' ;
$query = "insert into inquiry
(name,email,phone,treatment,gender,date) values ('$name','$email','$phone','$treatment','$gender','$date')";
if(mysqli_query($db_conx, $query)){
echo "<script>alert('Thank you for submitting your query, our doctors will call you soon!')</script>";
}
mail ( $to, $subject,
"From:" . $name .
", Email: " . $email .
", Number: ". $phone .
", Gender: " . $gender.
", Treatment: " . $treatment.
", Message: " . $message );
}
?>
尝试使用 header('Location: http://xxxxxxxx')
参考:http://php.net/manual/en/function.header.php
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>
这里有两个选择,
1) 你可以使用:
header('Location: http://domain.com/thank-you.html');
2) 使用javascript:
window.location.href='http://domain.com/thankyou.html';
此外, 您可以通过 Ajax post 您的邮件数据,如果数据成功 posted,您可以重定向 :)