PHP iframe重定向到另一个页面?

时间:2016-05-12 15:07:43

标签: php html iframe

到目前为止,我正在尝试使用php进行回声,而不是在它自己的name.php页面上,而是在我的index.html上,在提交按钮下面。

当前的HTML代码:

 <form autocomplete="off" action="test.php" method="post" target="iframe" accept-charset="UTF-8">
  <p>Passcode:</p>
  <input type="password" name="code"/><br>
  <input type="submit" value="Login" />
  <iframe name="iframe"></iframe>
</form>

当前的PHP代码:

$testcode = ("123");

  } else if ($pass === $testcode) {
    header('location: test.html');
  } else {
    echo "Try Again!";
  }

它有用,除非它成功,页面不会重定向到test.html但尝试在iframe中转到test.html。 但是,如果我将表单目标设置为_self,它会重定向到test.html,但不会在iframe中回显“再试一次”。

那么,如果输入正确的代码,我将如何重定向到test.html,如果代码不正确,请在提交按钮下面打印“再试一次”?

1 个答案:

答案 0 :(得分:0)

使用php无法实现此目的。因为

  

PHP是一种服务器端语言。

打开新窗口是客户端操作

所以你需要使用Jquery或javascript。