我在页面上有几个提交输入(按钮),具有以下isset条件:
if ( isset( $_POST[ 'noranTelChecks' ] ) ) { // user requested noranTelCheck sheet
header( 'location: noranTelChecks.php' );
} elseif ( isset( $_POST[ 'juniperChecks' ] ) ) { // user requested noranTelCheck sheet
header( 'location: juniperChecks.php' );
} elseif ( isset( $_POST[ 'mpr95001Checks' ] ) ) { // user requested noranTelCheck sheet
header( 'location: mpr95001Checks.php' );
} // close IF
Run Code Online (Sandbox Code Playgroud)
但无论点击什么按钮,页面总是被重定向到第一个IF条件引用的链接.如果我更改所引用链接的顺序,则始终是页面重定向到第一个条件中的链接.
上面的代码可能导致这个问题的问题,因为我过去在其他页面上做过这个并且它运行良好?
小智 1
我猜你的按钮已经设置了值
<input type="submit" id="noranTelChecks" name="noranTelChecks" value="Button 1"/>
Run Code Online (Sandbox Code Playgroud)
所以你可以使用值而不是名称或 ID。代码如下
if ( isset( $_POST["Button 1"] ) )
{
header( 'location: noranTelChecks.php' );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
242 次 |
| 最近记录: |