Jump to content

Something isnt right


eaglelegend

Recommended Posts

I have ended up dealeating, and dealeting more code off here trying to find out, why it wont let me log in (or any user) it just shows "Username Or Password incorrect, or something like that... heres my code

 

<?php
include("header.php");


         @$username = strip_tags(stripslashes($_POST['username'])); //assuming 'username' is the name of your form var
         @$password = strip_tags(stripslashes(md5($_POST['password']))); // ditto on 'password'


if($username && $password) {
$check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`='$username' AND `password`='$password'"));

if($check == 1) {
	        $_SESSION['ELv2'] = $username;
	        if(session_register('ELv2')){
 	 	Header("Location: index.php");
 	}
 	else {
 	 	print "Cant set cookie";
 	}
}
else {
 	print "Sorry, username/password mismatch!";
}

}
else {
?>
<h2>Login</h2><p>
<form action="http://www.<?php echo $SITEURL?>/login.php" method="post">
Username<br>
<input type="text" name="username" class="text_box" size="20" value="Username" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p>
Password<br>
<input autocomplete="off" type="password" name="password" class="text_box" size="20" value="password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p>
<input autocomplete="off" type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form>
<?php
}

include("footer.php");
?>

 

if someone could make me aware of what the problem is, I would be very greatful!

 

I have checked over the database, it turns out theres no errors there.

Link to comment
https://forums.phpfreaks.com/topic/123049-something-isnt-right/
Share on other sites

i would break out SQL for easier dev/test/debug:

 

$sql = "SELECT * FROM `members` WHERE `username`='$username' AND `password`='$password'";
$result = mysql_query($sql) or die(mysql_error());
$check = mysql_num_rows($result);
echo "check: $check<br>";
// etc.

 

 

Link to comment
https://forums.phpfreaks.com/topic/123049-something-isnt-right/#findComment-635388
Share on other sites

echo the SQL and see if there is a match in the database. see if the SQL is what you expect it to be, then run it in phpmyadmin or something. it's returning 0 records, which is why you're getting that error message. the idea is to figure out why it's returning 0 records. is the SQL right? apparently not, if you're expecting more than 0 records.

Link to comment
https://forums.phpfreaks.com/topic/123049-something-isnt-right/#findComment-635401
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.