SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    isset and incrementing

    I thought I knew how to $increment++ but maybe part of the problem is something else.

    My form has a number of error messages for un-filled in fields, but I do NOT want these to display until the Form submit button is clicked (those who accurately fill in the form should not have to see any error messages).

    If I access the page directly, everything works fine. But in coming to it from a previous page with a form & method=POST & Sessions, could this part of the problem?

    Here's my code:
    PHP Code:
    ...top of page session stuff...
    $showerrors = "1";
    if (isset($_POST['submit'])) {
    $showerrors++;
    ...error message logic
    ...html + form header + html
    <?php 
    if(($error != "") && ($showerrors >= 3)) {
    echo 
    "<center><b><font class=\"error\">";
    echo 
    "SORRY, BUT THE FOLLOWING ERROR(S) OCCURRED:<br><br>";
    echo 
    $error;
    echo 
    "</font></b></center><br>";
    }
    ?>
    ...more html
    ...Submit Button
    I've tried different numbers in the $showerrors, using double-quotes, double =='s, etc.

    Hope someone can help with this. Thanks.

  2. #2
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't be quoting numbers. Only strings should be quoted.

    Try using if(!empty()) rather than isset()

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Phil.Roberts (are you the same PR from the IPB Forum???)

    I ditched the " "'s but still can't get things right.

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RocketMan
    Thanks, Phil.Roberts (are you the same PR from the IPB Forum???)

    I ditched the " "'s but still can't get things right.
    Hmm -- can you show us the entire code for the page?

    The $error variable *does* need to be set -- is it getting a value? (i.e. echo $error just before checking if it != "")
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

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