Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,486
    Thanks
    279
    Thanked 32 Times in 31 Posts

    checking post submit first or not

    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

    Code:
     if (!empty($_POST['userlevel'])) {
    
                if ($_POST['Submit']) {
    as apposed to

    Code:
     if ($_POST['Submit']) {
    
    
     if (!empty($_POST['userlevel'])) {
    does it really make any dif in security or functionality! as long as they get checked?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,486
    Thanks
    279
    Thanked 32 Times in 31 Posts
    ok thanks so

    Code:
     if (isset($_POST['Submit']))
    it is, and it comes first... thanks so much..


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •