簡體   English   中英

如果/ elseif`isset`多個提交輸入不起作用

[英]if / elseif `isset` multiple submit inputs doesn't work

在頁面上,我有幾個提交輸入(按鈕),具有以下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

但無論點擊什么按鈕,頁面總是被重定向到第一個IF條件引用的鏈接。 如果我更改所引用鏈接的順序,則始終是頁面重定向到第一個條件中的鏈接。

上面的代碼可能導致這個問題的問題,因為我過去在其他頁面上做過這個並且它運行良好?

我猜你的按鈕設置了值例如

<input type="submit" id="noranTelChecks" name="noranTelChecks" value="Button 1"/>

所以你可以使用值而不是name或id。 代碼如下

if ( isset( $_POST["Button 1"] ) ) 
{ 
    header( 'location: noranTelChecks.php' );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM