ritesh.taurani Posted January 7, 2010 Share Posted January 7, 2010 wen m running d code i get the o/p as First Name: Last Name: username: zipcode: add1: ma code is: <HTML> <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("project",$db); $result = mysql_query("SELECT * FROM customer_master WHERE userid='$username' and password=PASSWORD('$password')",$db); $myrow = mysql_fetch_array($result); echo "First Name: ".$myrow["fname"]; echo "<br>Last Name: ".$myrow["lname"]; echo "<br>username: ".$myrow["userid"]; echo "<br>zipcode: ".$myrow["zip"]; echo "<br>add1: ".$myrow["add1"]; ?> </HTML> d value is nt gettin fetchd by database Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/ Share on other sites More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 theres no where in that where a $username or $password variable is declared so it isn't going to return any results from your database Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990176 Share on other sites More sharing options...
trq Posted January 7, 2010 Share Posted January 7, 2010 On a side note. The mysql PASSWORD function should not be used to hash passwords. This function is known to change between mysql versions which will break your data. Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990177 Share on other sites More sharing options...
ritesh.taurani Posted January 7, 2010 Author Share Posted January 7, 2010 theres no where in that where a $username or $password variable is declared so it isn't going to return any results from your database but the username has to be retieved from form Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990186 Share on other sites More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 maybe if you showed us the whole code? Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990205 Share on other sites More sharing options...
ritesh.taurani Posted January 7, 2010 Author Share Posted January 7, 2010 i have a login form with 2 fields username password and in the action of dat form i have dat php code which i posted Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990211 Share on other sites More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 so im guessing the form looks something like.. <form action="filename.php" method="GET"> Username: <input type="text" name="username"> Password: <input type"password" name="password"> <input type="submit" value="Login"> In which case for what you need: <HTML> <?php $username=$_GET['username']; $password=$_GET['password']; $db = mysql_connect("localhost", "root", ""); mysql_select_db("project",$db); $result = mysql_query("SELECT * FROM customer_master WHERE userid='$username' and password=PASSWORD('$password')",$db); $myrow = mysql_fetch_array($result); echo "First Name: ".$myrow["fname"]; echo "<br>Last Name: ".$myrow["lname"]; echo "<br>username: ".$myrow["userid"]; echo "<br>zipcode: ".$myrow["zip"]; echo "<br>add1: ".$myrow["add1"]; ?> </HTML> let me know if that works. Link to comment https://forums.phpfreaks.com/topic/187543-can-i-knw-wat-is-my-error/#findComment-990215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.