php - 来自一页的两次重定向
问题描述
如何通过单击两个不同的按钮从一个 html 页面重定向到两个不同的 php 页面?我有两个按钮,btn1 和 btn2
*如果我点击 btn1,html 页面页面应该重定向到page1.php表单值。
*以同样的方式,如果我点击 btn2,html 页面页面应该重定向到page2.php与表单值。
<form action = "check.php" method = "post">
<div align = "center">
<table>
<thead><h2>LOGIN FORM<h2></thead>
<tr>
<td><h4>Username</h4></td>
<td><input type = "text" name = "username"></td>
</tr>
<tr>
<td><h4>Password</h4></td>
<td><input type = "password" name = "password"></td>
</tr>
<tr>
<td><button name = "register">Sign up</button></td>
<td><button name = "submit">Login</button></td>
</tr>
</table>
</div>
</form>
在这里,如果我点击登录,我必须转到 check.php,如果我点击注册,它应该被重定向到 sample.php。
但是在上面的代码中,我只能重定向到一个 php 文件。
如何将注册按钮重定向到另一个 php 文件?
解决方案
相反,您可以重定向到一个页面并添加两个功能:
由于您已经将登录按钮命名为提交,在php文件中检查是否设置了提交,如果是,则添加登录操作。如果不是,则在else部分添加sign up的操作。
推荐阅读
- sql-server - 使用 VBA 记录集将 Excel 工作表导出到 SQL Server 表
- sql-server - 带有 MSSQL Express 的 Power BI 服务器
- botframework - 机器人在模拟器中返回 0
- javascript - Javascript整数数组错误
- asp.net-mvc - MVC Bootstrap 没有显示图标
- c++ - Ubuntu 下 Cmake 和 Intel IPP 的编译问题
- reactjs - this.props."value" 传递给 onSubmit 时未定义
- c - 在存储之前格式化用户输入的最佳方式(C)?
- c# - 数据源到asp日历
- excel - 将列字母转换为数字