Hi all. I'm going to use md5() to store passwords in my database, and I'm just wondering about the use of md5() and sprintf().
In the security section of the php docs there's the following example:
// storing password hash
$query = sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
addslashes($username), md5($password));
$result = pg_exec($connection, $query);
what I'm wondering is what is the difference between that and the following:
$query = "INSERT INTO users(name,pwd) VALUES('".addslashes($username)."','".md5($password)."');"
$result = pg_exec($connection,$query);
what is the effect of using sprintf() on the query.
When I use the following code the results are exactly the same:
echo "username=".$_GET['username']." password=".md5($_GET['password'])."<br>";
echo sprintf("username=%s password=%s",$_GET['username'],md5($_GET['password']));
Thanks in advance.
P.