Calgaryalberta Posted February 20, 2008 Share Posted February 20, 2008 Yesterday I posted a topic I thought was solved, but it looks as if its not. I have a login script I wrote labeled index.htm, and the checklogin.php will be below the index.htm (checklogin.php) handles the form from index.htm. When trying to login it returns "Wrong username/password" the username/password is not wrong, and the script looks fine to me, any suggestions on how I can fix this? (The username/pw do exist in the db) index.htm <table cellSpacing="3" cellPadding="0" width="100%"> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername1" type="text" id="myusername1" size="20"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword1" type="password" id="mypassword1" size="20"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> </table> checklogin.php <?php $host="****"; // Host name $username="****"; // Mysql username $password="****"; // Mysql password $db_name="****"; // Database name $tbl_name="****"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $myusername = $_POST['myusername1']; $mypassword = $_POST['mypassword1']; $sql = "SELECT * FROM $tbl_name WHERE mysername = '$myusername' AND mypassword = '$mypassword'"; $result = @mysql_query($sql); // Mysql_num_row is counting table row $count = @mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count == 1) { // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername1"); session_register("mypassword1"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> Theres no parse errors or anything, its just returning a "Wrong Username/Password" when the username/password are correct, any tips? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 20, 2008 Share Posted February 20, 2008 session_register is de-appreciated try <?php session_start(); $_SESSION["myusername1"]; $_SESSION["mypassword1"];?> Quote Link to comment Share on other sites More sharing options...
revraz Posted February 20, 2008 Share Posted February 20, 2008 When you create the password, are you hashing it somehow? Because right now you are comparing it to plain text. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 20, 2008 Share Posted February 20, 2008 reveraz was right try <?php $mypassword = md5($_POST['mypassword1']); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.