php提交重定向到另一个页面 [英] php on submit redirect to another page
本文介绍了php提交重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 html 文档中有一个表单,当按下提交按钮时,表单调用文件 form.php.现在在 form.php 中,我想将它重定向回我的主页并重置以前填写的表单.我已经尝试了下面的代码,但我得到了一个空白页.谷歌网址只是默认的.
I have a form in my html document and when press submit button, the form calls the file form.php. Now in the form.php, i want to redirect it back to my home page and reset the previous filled form. I have tried the code below but I got a blank page. The Google url is just default.
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
// To redirect to home page
header("Location:http://www.google.com");
} else {
echo '<p>Oops! An error occurred. Try sending your message again.</p>';
}
}
?>
感谢大家的帮助.
推荐答案
可以试试javascript的页面重定向方式:
You can try the javascript way of redirecting the page:
示例:
$url='http://www.google.com';
echo '<script>window.location = "'.$url.'";</script>';
die;
这可能会有所帮助...!!
It may help ...!!
这篇关于php提交重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文