为什么location.replace在PHP文件中不起作用?

时间:2019-05-23 16:38:16

标签: javascript php html css

我试图在单击按钮但在相同的选项卡和窗口中时打开一个PHP文件,但是代码不起作用。我读过一个类似的问题,它说我们应该在按钮中使用return false,但是不起作用。

<script>
function openlog() {
  location.replace("login.php")
}
</script>
<?php header('Content-Type: text/html; charset=utf-8');?>
<!DOCTYPE HTML PUCLIC "-//W3C//DTDHTML
4.0 Transitional//EN"><HTML>
  <HEAD>
      <link rel="stylesheet" type="text/css" href="startstyle.css">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </HEAD>
  <BODY>

  <p align="left"><FONT FACE="Times New Roman"> <span class="starting_text">
    Please Select one of the following if you are an employee or member of the Library <br>
    If you don't have an account click login and then signup </p>

  <FORM METHOD="post" ACTION="start.php">

  <button class="btn" id="button1" TYPE="submit" name="submit" onclick="openlog()" return false;>LOG IN AS EMPLOYEE </button>
  <br>
  <br>
  <button class="btn" id="button2" TYPE="reset" name="Reset">LOG IN AS MEMBER      </button>
</BODY>
</FORM>
</HTML>

1 个答案:

答案 0 :(得分:0)

对于有相同问题的任何人,我都可以这样解决:

<input type="button" class="btn" id="button1" TYPE="submit" name="submit" onclick="window.location.href='login.php'" value="LOG IN AS EMPLOYEE">  </button>
  <br>
  <br>
  <input type="button" class="btn" id="button1" TYPE="submit" name="submit" onclick="window.location.href='loginmember.php'" value="LOG IN AS MEMBER">  </button>

并删除了javascipt部分。