...

View Full Version : sha1 error



simjay
11-28-2007, 06:24 PM
hello

To get the password from the database i use this:


$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?

the game hog
11-28-2007, 08:08 PM
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.



<?

//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.


<?

$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?:confused:

Inigoesdr
11-28-2007, 08:16 PM
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() (http://php.net/var_dump) to show exactly what the value of each one is.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum