不同的页面>条款和条件>不同的页面

时间:2015-04-08 22:56:08

标签: php redirect

这很难解释,但我遇到了'条款& amp;条件页面。

我需要制作一个术语和一个条件,但不同的页面让用户得到这个条款,并根据他来自的页面,在同意后,他被重定向到通讯页面。

有点

A1.php>条款和conditions.php> A2.php

B1.php>条款和conditions.php> B2.php

这个条款&条件页面对每个人都是一样的,但我如何根据用户来自何处进行重定向?这可能吗?

谢谢。

2 个答案:

答案 0 :(得分:2)

大多数人,以及最可靠的工作是添加某种url变量。而不是重定向到terms_and_conditions.php,而是像这样重定向:

B1.php > terms_and_conditions.php?redirect=A2.php > A2.php
B1.php > terms_and_conditions.php?redirect=B2.php > B2.php

答案 1 :(得分:1)

接下来是一个如何做到这一点的真实例子。 Lucas,您将需要创建5个文本文件,使用下一个给定名称命名,将代码复制粘贴到相应的文件,最后打开浏览器并键入:“localhost / a1.php”和“localhost /” b1.php”。

<强> a1.php

<html>
  <body>
    This is A1. To enter A2 you have to accept Terms and Conditions.
    <br/>
    <br/>
    <form method="post" action="terms_and_conditions.php">
      <input type="text" value="a2.php" name="next_page" style="display:none"/>
      <input type="submit" value="Go to Terms and Conditions"/>
    </form>
  </body>
</html>

<强> b1.php

<html>
  <body>
    This is B1. To enter B2 you have to accept Terms and Conditions.
    <br/>
    <br/>
    <form method="post" action="terms_and_conditions.php">
      <input type="text" value="b2.php" name="next_page" style="display:none"/>
      <input type="submit" value="Go to Terms and Conditions"/>
    </form>
  </body>
</html>

<强> terms_and_conditions.php

<html>
  <body>
    Terms and Conditions
    <br/>
    <br/>
    Bla bla bla bla bla ...
    <br/>
    <br/>
    <form method="post" action="<?php echo $_POST['next_page']; ?>">
      <input type="submit" value="Accept Terms and Conditions"/>
    </form>
  </body>
</html>

<强> a2.php

<html>
  <body>
    This is A2. Thanks for accepting Terms and Conditions.
  </body>
</html>

<强> b2.php

<html>
  <body>
    This is B2. Thanks for accepting Terms and Conditions.
  </body>
</html>

棘手的部分是 terms_and_conditions.php 。请注意操作,该值来自PHP。这就是许多页面只能使用一个条款和条件的方式。

下一个要打开的页面位于 a1.php b1.php 。看一下名为“next_page”的输入文本(display:none)。每个页面都必须更改“值”。