sanderphp Posted May 20, 2008 Share Posted May 20, 2008 I recently updated my login page to add a register button but for some reason I can't login in anymore using any of my accounts. I get my "wrong username or password" error. I keep thinking that I must have changed the function of the login button or something. <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="login" type="text" id="login"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td width="5%" > <input type="submit" name="login" value="login"></td> <td width="5%" > <input type="button" value="register" onclick="window.location.href='registrationbackup.php';"></td> </tr> if(isset($_POST['login'])){ // Define $myusername and $mypassword $myusername=$_POST['login']; $mypassword=$_POST['password']; // To protect MySQL injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT id FROM $tbl_name WHERE login='$myusername' and password='$mypassword'"; // get the id $result=mysql_query($sql); if (!$result) { print "$sql<br>"; print mysql_error()."<br>"; } // 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['username'] = $myusername; $_SESSION['password'] = $mypassword; $_SESSION['login_id'] = mysql_result($result, 0); // store the id header("location:login_success.php"); } else { echo "Wrong Username or Password"; } Link to comment https://forums.phpfreaks.com/topic/106412-solved-login-form-possibly-not-functioning-correctly/ Share on other sites More sharing options...
phpretard Posted May 20, 2008 Share Posted May 20, 2008 So if you take away the register button you can log in? Link to comment https://forums.phpfreaks.com/topic/106412-solved-login-form-possibly-not-functioning-correctly/#findComment-545438 Share on other sites More sharing options...
mjcoco Posted May 20, 2008 Share Posted May 20, 2008 <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="login" type="text" id="login"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td width="5%" > <input type="submit" name="login" value="login"></td> <td width="5%" > <input type="button" value="register" onclick="window.location.href='registrationbackup.php';"></td> </tr> first maybe change the login for each name, textfield and submit. Since you have login for the input for text and for the submit. second im not sure that onclick="window.location.href='registrationbackup.php';" is necessary, you can probably just use onclick="registrationbackup.php" Also try print 'alert($myusername);'; see what it gives you, if its giving you what you typed and whats in your database, its you query Link to comment https://forums.phpfreaks.com/topic/106412-solved-login-form-possibly-not-functioning-correctly/#findComment-545442 Share on other sites More sharing options...
sanderphp Posted May 20, 2008 Author Share Posted May 20, 2008 no. I must have changed some action. Does this look right? <form name="form1" method="post" action="checklogin.php"> <td> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="login" type="text" id="login"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td width="5%" > <input type="submit" name="login" value="login"></td> <td width="5%" > <input type="button" value="register" onclick="window.location.href='registrationbackup.php';"></td> Link to comment https://forums.phpfreaks.com/topic/106412-solved-login-form-possibly-not-functioning-correctly/#findComment-545446 Share on other sites More sharing options...
sanderphp Posted May 20, 2008 Author Share Posted May 20, 2008 changing "login" to enter did it! thanks Link to comment https://forums.phpfreaks.com/topic/106412-solved-login-form-possibly-not-functioning-correctly/#findComment-545448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.