If / elseif `isset` multiple send inputs do not work

I have several input inputs (buttons) on a page with the following isset conditions:

 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 

But no matter which button is pressed, the page is always redirected to the link to which the first IF condition refers. If I change the order of the links, the link is always the link in the first condition to which the page is redirected.

What could be the problem with the above code causing this problem, as I did in the past on other pages, and it worked fine?

+7
php isset
source share
1 answer

I think your buttons have values ​​set, for example,

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

so that you can use a value instead of a name or id. The code will look like this

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

All Articles