Results 1 to 5 of 5

Thread: My password code doesn't seem to work...

  1. #1
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My password code doesn't seem to work...

    PHP Code:
    <?php

    if(file_exists("".$_POST['name']."password.php")) {

    include(
    "".$_POST['name']."password.php");

      if(
    $real $_POST['pass'])
      { 
    Posting code here
    } else { echo("Password is wrong.");}
    } else {
    $ft fopen("".$_POST['name']."password.php""a+");
    fwrite($ft"<?php
    \$real = "
    .$_POST['pass']."
    ?>"
    );

    Posting code again
    }
    ?>
    This code should check if the file exists, and if it does, check if the password entered is the true password, and if that is right, then post. If not, say the password is wrong. And if the file doesn't exist yet, create it and write the password entered for the name (indicated by the file), then continue to post.

    It always posts, no matter what.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    if($real = $_POST['pass'])
    Don't confuse assignment and comparison. == and === compare two values and return true or false depending on whether they are equal; = assigns the right-hand value to the left-hand value, then returns the right-hand value. For the purposes of that if statement, that may as well be:
    Code:
      if($_POST['pass'])
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I noticed that and fixed it, but now it's acting as if the back to back else's aren't allowed...saying unexpected T_ELSE.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Oh, yeah, that's not allowed either. You have to have a condition for each else clause.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's why I have an if inside of an if, which is allowed, no? How am I supposed to handle that, then?

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
  •