ted_chou12 Posted December 24, 2006 Share Posted December 24, 2006 [code]<?php require("../mysqlconnection.php"); $sql = "SELECT username FROM userinfo WHERE username = '$username'"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $pass = $row['password']; if($md5pass == $pass) return true; else return false;}?>can anyone have a look at this? because it doesnt get both the uesrname and password at all....THanksTed[/code] Link to comment https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/ Share on other sites More sharing options...
fert Posted December 24, 2006 Share Posted December 24, 2006 change[code]$sql = "SELECT username FROM userinfo WHERE username = '$username'";[/code]to[code]$sql = "SELECT password FROM userinfo WHERE username = '$username'";[/code] Link to comment https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/#findComment-147386 Share on other sites More sharing options...
ted_chou12 Posted December 24, 2006 Author Share Posted December 24, 2006 by the way, my password stored in the database is md5 coded... Link to comment https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/#findComment-147387 Share on other sites More sharing options...
kenrbnsn Posted December 24, 2006 Share Posted December 24, 2006 You're only asking for the username from the DB. If you want to retrieve the password you have to ask the DB for it.[code]<?php require("../mysqlconnection.php"); $sql = "SELECT username, password FROM userinfo WHERE username = '$username'"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $pass = $row['password']; if($md5pass == $pass) return true; else return false;}?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/#findComment-147388 Share on other sites More sharing options...
ted_chou12 Posted December 24, 2006 Author Share Posted December 24, 2006 thanks, I understand Link to comment https://forums.phpfreaks.com/topic/31778-hi-i-need-help-with-this/#findComment-147390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.