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

Thread: sha1 error

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    153
    Thanks
    1
    Thanked 0 Times in 0 Posts

    sha1 error

    hello

    To get the password from the database i use this:

    PHP Code:
    $password2 sha1(strip_tags($_POST['user_password']));

    echo 
    "password"

    How would i change it so if i was adding to the database? Because when i add a new password its differnt to what it would be if im getting from the database?

  • #2
    New Coder
    Join Date
    Oct 2007
    Location
    Irwin, PA
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I'm not sure what your asking, but I can try to help.

    First off, why are you using strip_tags? If you are trying to enter a password into a database, you can simply insert it as so.

    PHP Code:
    <?

    //this is all you need to collect the post password
    $password2 $_POST['password'];

    ?>
    If you want to make it secure you mean, you can always use the MD5 function and insert it into a database.
    PHP Code:
    <?

    $password2 
    $_POST['password'];

    $password3 md5($password2);

    ?>
    One more thing, you used this:
    echo "password";

    If you are trying to print the variable, just print that or in double quotes:
    echo $password2;

    or

    echo("Password entered: $password2");

    Did I answer your question?

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Just remove the strip_tags() function. It's not needed because the input(everything, tags or not) will be hashed into a string. As long as you use the same method to store the password, and hash the password when the user is logging in the result should match. If you're having a problem when comparing the variables use var_dump() to show exactly what the value of each one is.


  •  

    Posting Permissions

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