Results 1 to 4 of 4

Thread: [RESOLVED] if - it always worked for me but this time not? what did i do wrong..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    27

    Resolved [RESOLVED] if - it always worked for me but this time not? what did i do wrong..

    you can see it working here, that it doesn't work:
    http://vba.lescigales.org/serialcheck.php
    the code i used is this:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input type="text" name="serial" id="serial" />
      </label>
      <label>
      <input type="submit" name="button" id="button" value="Submit" />
      </label>
    </form>
    <?php
    $a 
    "9d5e3ecdeb4cdb7acfd63075ae046672";
    $b "lol";
    if(
    $_POST['serial'] = "")
    {
    //do nothing, it's empty!
    }
    else
    {
      if(
    $_POST['serial'] == $a or $b)
      {
      
    //Do something here to tell the dude he's allowed!
      
    echo "allowed!";
      } 
      else
      {
      echo 
    "not allowed";
      }
    }
    ?>
    </body>
    </html>
    it always says allowed..

    thanks for helping..
    - Shadows.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: if - it always worked for me but this time not? what did i do wrong..

    change

    if($_POST['serial'] == $a or $b)

    to

    if($_POST['serial'] == $a || $_POST['serial'] == $b)


    You weren't comparing $b to anything.

    Also, you need to restructure your code. You should never have something like
    PHP Code:
    if($_POST['serial'] = "")
    {
    //do nothing, it's empty!


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    27

    Re: if - it always worked for me but this time not? what did i do wrong..

    kool thanks ^^
    did this:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input type="text" name="serial" id="serial" />
      </label>
      <label>
      <input type="submit" name="button" id="button" value="Submit" />
      </label>
    </form>
    <?php
    $a 
    "9d5e3ecdeb4cdb7acfd63075ae046672";
    $b "lol";
    if(!empty(
    $_POST['serial']))
    {
      if(
    $_POST['serial'] == $a || $_POST['serial'] == $b
      {
      
    //Do something here to tell the dude he's allowed!
      
    echo "allowed!";
      } 
      else
      {
      echo 
    "not allowed or empty";
      }
    }
    ?>
    </body>
    </html>
    if !empty doesn't work tho it seems..

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: [RESOLVED] if - it always worked for me but this time not? what did i do wrong..

    I prefer isset.

    PHP Code:
    if(isset($_POST['serial'])) 
    But if you mean "not allowed or empty" isn't appearing, it is because your else is linked to your

    if($_POST['serial'] == $a || $_POST['serial'] == $b)

    if, not your empty if.

    The code should be

    PHP Code:
    if(!empty($_POST['serial']))
    {
      if(
    $_POST['serial'] == $a || $_POST['serial'] == $b)
      {
      
    //Do something here to tell the dude he's allowed!
      
    echo "allowed!";
      } 
    //end the post if
    //end the empty if
    else
      {
      echo 
    "not allowed or empty";
      } 
    //end the else 

Posting Permissions

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



Click Here to Expand Forum to Full Width