wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 Okay run this:[code]<?phpsession_start();$conn = mysql_connect("localhost", "lov3dco_users", "test") or die('Unable to connect to MySQL');// select what database to usemysql_select_db("lov3dco_users", $conn) or die('Unable to select database - lov3dco_users');// get the username from the form, as $username$username = mysql_real_escape_string($_POST['username']);// get the password from the form in md5$password = md5($_POST['password']);$recieve = "SELECT * FROM users WHERE username='$username' AND `password`='$password'";$query = mysql_query($recieve, $conn) or die("Unable to peform query - " . mysql_error()); //do the queryif(mysql_num_rows($query) == '1'){ echo "login successful";}else{ echo "login failed";}echo "<br /><br /><b>DEBUG INFO:</b><br /><code><b>Username</b>: {$username}<br /><b>Password</b>: {$_POST['password']}<br /><b>Password Hash</b>: {$password}<br /><b>MD5 Hash of 'test'</b>: " . md5('test') . "<br /><b>MD5 Hash TEST</b>: " . ((md5('test') == $password) ? 'passed' : 'failed') . "<br /><b>Query</b>: {$recieve}<br /></code>";?>[/code]This time it gives you some debug info.Post the debug info it produces here. Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67192 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 [code]login failedDEBUG INFO:Username: testPassword: tetsPassword Hash: 45edd741812abf42a7b799a6fc558d9cMD5 Hash of 'test': 098f6bcd4621d373cade4e832627b4f6MD5 Hash TEST: failedQuery: SELECT * FROM users WHERE username='test' AND `password`='45edd741812abf42a7b799a6fc558d9c'[/code]TETS?! this means..? Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67195 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 You are using the incorrect password. The password you want to use is test and not tetsThe DEBUG is what I create with login scripts when they dont work etc. It just shows whats going on. Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67196 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 Argh omw, was filling it in automatically for a while using FF... but now that it's resolved -what script can i finally use?! :DMany thanks for all your help - i'll be sure to link back to you from all my sites in future!! ;D Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67199 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 Change this:[code]if(mysql_num_rows($query) == '1'){ echo "login successful";}else{ echo "login failed";}echo "<br /><br /><b>DEBUG INFO:</b><br /><code><b>Username</b>: {$username}<br /><b>Password</b>: {$_POST['password']}<br /><b>Password Hash</b>: {$password}<br /><b>MD5 Hash of 'test'</b>: " . md5('test') . "<br /><b>MD5 Hash TEST</b>: " . ((md5('test') == $password) ? 'passed' : 'failed') . "<br /><b>Query</b>: {$recieve}<br /></code>";[/code]to this:[code]if(mysql_num_rows($query) == '1'){ $_SESSION['password'] = $password; //store the users password in a sesions var $_SESSION['username'] = $username; //store the username in a session var header('Location: index.php');}else{ session_destroy(); echo "login failed, please try again";}[/code]and you should be set to go, fingers crossed Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67203 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 I am back I am glad you 2 figured it out and everything is running now. Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67205 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 WOOOO Thanks guys, very very much appreciated ;D ;D Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67218 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 thanks too wildteen for the debug thing, that'll help too later. Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/3/#findComment-67221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.