提交联系表后重定向到主页并说谢谢

时间:2013-10-25 03:32:15

标签: php html

我试图让我的网站在提交联系表单后重定向到主页,然后转到感谢页面。我有它工作得很好,除了重定向AFTER感谢页面,它适用于我删除感谢页面。我知道我需要在该行之后使用一个声明,然后是标题(www.google.com)类型的东西,但不确定要为if语句放置什么。

我将我的联系表单文件上传到下面的保管箱链接,如果有人能让我走上正确的轨道,那就太棒了。提前谢谢。

https://www.dropbox.com/sh/2zrci8b04989u3d/gEc3u6rPK4

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
      <title>Thank you!</title>
      <link rel="STYLESHEET" type="text/css" href="contact.css">
</head>
<body>

<script>
window.onload=function() {
  setTimeout(function() {
    location.replace("index.php");
  },3000); // wait 3 seconds
}
</script>
<h2>Thank you...</h2>
<a href="index.php">click here if you are not redirected in a few seconds</a>

</body>
</html>

3 个答案:

答案 0 :(得分:2)

因为我在手机上没有查看页面,请将其放在感谢页面

<script>
window.onload=function() {
  setTimeout(function() {
    location.replace("somepage.php");
  },3000); // wait 3 seconds
}
</script>
<h2>Thank you...</h2>
<a href="somepage.php">click here if you are not redirected in a few seconds</a>

答案 1 :(得分:0)

尝试这样的事情,以防用户确实禁用了javascript:

<?php

header( "Refresh: 5 url=http://yourdomain.com/" );

?>
<!DOCTYPE html>
<html>

<!-- HTML CODE GOES HERE -->

</html>

header()函数中的数字5是页面将用户重定向到网址之前的秒数。 header函数必须出现在任何html和/或php输出

之前

答案 2 :(得分:0)

你可以用3种方式做到这一点。

1 - Html重定向:

<!doctype html>
<head>
<META http-equiv="refresh" content="0;URL=http://www.example.com">
</head><body></body></html>

2 - PHP标头重定向:

<?php
header('Location: http://www.example.com');
?>
<!doctype html><html><head></head><body></body></html>

3 - Javascript重定向:

<!doctype html><html><head>
<script>
window.location.assign("http://www.example.com");
</script>
</head><body></body></html>