klepec Posted April 6, 2012 Share Posted April 6, 2012 I have multiple forms within one php file. What is the best structure to use? if (isset($_POST["one"])) { include... } if (isset($_POST["two"])) { include... } if (isset($_POST["three"])) { include... } OR if (isset($_POST["one"])) { include... } else if (isset($_POST["two"])) { include... } else if (isset($_POST["three"])) { include... } thanks Link to comment https://forums.phpfreaks.com/topic/260451-if-structure/ Share on other sites More sharing options...
AyKay47 Posted April 6, 2012 Share Posted April 6, 2012 It depends if you want the possibility of multiple blocks to be executed or not. Link to comment https://forums.phpfreaks.com/topic/260451-if-structure/#findComment-1334932 Share on other sites More sharing options...
klepec Posted April 6, 2012 Author Share Posted April 6, 2012 Only one. Just the chosen form where submit button is set. I know there cant be multiple buttons submitted, but just for the extra protection. Link to comment https://forums.phpfreaks.com/topic/260451-if-structure/#findComment-1334933 Share on other sites More sharing options...
AyKay47 Posted April 6, 2012 Share Posted April 6, 2012 if it makes you sleep better at night, use the else if method, or even a switch statement. Link to comment https://forums.phpfreaks.com/topic/260451-if-structure/#findComment-1334938 Share on other sites More sharing options...
klepec Posted April 6, 2012 Author Share Posted April 6, 2012 hehe okay, thanks Link to comment https://forums.phpfreaks.com/topic/260451-if-structure/#findComment-1334944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.