SELECT password from users where username = "$username"?

Hello everyone,

I created a register.php page, and haver user enter the username and password. Once they enter it, I then create a login.php page.

So now user that logins in can enter username and password. so if they enter a username and supposely this username is in the database, how can i query out the username’s associated password?

is it this code?



  $result = mysql_query("select password from users where username ='$username'");

 $info = mysql_fetch_array( $result);


Echo " $info[password]<br>"; 

thanks

That SQL query will work.

You may also want to check the number of rows returned from the database. If it’s 0, the account doesn’t exist.

http://php.net/mysql_num_rows

ok thanks.