Suppose I have a database table consisting of three columns – Userid, Username & Password. And let’s assume I am building a Log-in Form and the password is stored in encrypted form. So, before it can be compared with the original password, it needs to be processed a little.
So, I let the user enter the username and password in the form.
include('db.php');
$getuid = $connection->prepare('SELECT FROM users WHERE username = :u');
$getuid->execute(array("u" => $_REQUEST['username']));
Now, I have executed the statement, and the row with the Entered Username is selected.
What I Want to Do ?
After Selecting the Row, I want the corresponding Password(which is in encrypted form) and Userid to be stored in $pass, $userid variables. How can I do that?
the
selectquery needs to be$getuid = $connection->prepare('SELECT * FROM users WHERE username = :u');where*selects/gets all columns from the table users.Then traverse the results, as per their column names (username, and say pwd) to get their corresponding values, as shown below:
Note: you cannot retrieve the original or decoded password, its explained nicely here