View Full Version : checking post submit first or not

11-23-2010, 08:27 PM
hi, just curious, does it matter in the process if i check post submit first or second to the post var

so if i have

if (!empty($_POST['userlevel'])) {

if ($_POST['Submit']) {

as apposed to

if ($_POST['Submit']) {

if (!empty($_POST['userlevel'])) {

does it really make any dif in security or functionality! as long as they get checked?

11-23-2010, 09:35 PM
In terms of functionality, simply checking $_POST['Submit'] could return in an error (based on how you're doing it, could also fail automatically in IE in terms of checking, as IE6 for example doesn't carry the value of a submit button, just that its set... so you need to check if its set). Otherwise, why check if the value exists first then if its submitted? The logic is backwards, and can cause headaches down the road. Always take the most logical path, it is programming after all.

11-23-2010, 10:00 PM
ok thanks so

if (isset($_POST['Submit']))

it is, and it comes first... thanks so much..