在我的index.php中,我有两个表单,当单击相应的链接时,它使用转换来移动页面(登录注册,反之亦然)。当我试图在后端注册时,我正在检查用户是否存在。如果用户确实存在,那么我将重定向到index.php,这是主文件。问题是,登录页是默认页面,在刷新index.php时加载该页面。在后台代码中运行头函数后,我尝试运行一个js,以编程方式单击登录页中的寄存器页链接。但似乎不起作用。
index.php ->包含两个注册和登录表单。
<html>
<form action="register.php" method="post">
<button type=submit>
</form>
<form action="login.php" method="post">
<button type=submit>
</form>
</html>register.php
if (user_exist){
header("Location: index.php"); //redirects to index.php
}上面的标题重定向到index.php,特别是登录页面,但我需要注册页面。有没有一种方法可以使用标头内的表单ID或类来进行转换?
发布于 2022-06-29 19:36:25
您只需调用header函数并指定Location,如下所示:
header('Location: your/path/to/the/page');https://stackoverflow.com/questions/72806885
复制相似问题