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
    New Coder
    Join Date
    Jul 2006
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Leaving Fields Blank Help...

    Basically...

    I have got...

    PHP Code:
    if (empty($name))
            {
            echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your name, please go back and fill your name in the required field.</span></div>';
            include 
    'quote.htm';
            } 
            elseif(empty(
    $email))
            {
            echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your email address, please go back and fill your email address in the required field.</span></div>';
            include 
    'quote.htm';
            }
            elseif (empty(
    $other))
            {
            echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter any information about what you would like designing, please go back and fill in all the information possible in the required field.</span></div>';
            include 
    'quote.htm';
        exit();
            }
            else 
    And what i'd like to do is make them ALL come up if they are ALL left blank.. the way it is atm, only 1 of them comes up at a time.

    For example, if 'name' and 'email' are left blank... only name will come up as an error message.

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you're not qutie clear about what should happen if 2 of the 3 are blank...I'll assume you want two error messages...
    It's also not apparent what quote.htm contains, but I'll assume you only want that once, no matter how many error messages:
    You've also got a dangling else at the end, but I assume that contains the code for 'no errors'...
    PHP Code:
    $errors=false;
    if (empty(
    $name)) { 
    $errors=true;
      echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your name, please go back and fill your name in the required field.</span></div>'
    }  
    if(empty(
    $email)) 

    $errors=true;
      echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your email address, please go back and fill your email address in the required field.</span></div>'
    }
    if (empty(
    $other)) 

    $errors=true;
      echo 
    '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter any information about what you would like designing, please go back and fill in all the information possible in the required field.</span></div>'
    }
    if(
    $errors) {
        include 
    'quote.htm'
        exit(); 
    }
    else {  
    //the exit makes this not entirely necessary...
    //no errors


  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You got it all right Sorry I wasn't overally clear, was typing it in a rush.

    Thanks for your help.


  •  

    Posting Permissions

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