Hello, i have mentioned my code here already. I have a self made database with around 2 users only. So, when i enter correct information. I still get the message "Log In Not Accepted"!. The Error is in the line where $query is set. Because, on entering correct information. The num_rows() function returns ZERO. Also, since i am a beginner and working on a localhost, so i haven't added PD and all. if (isset($_POST['userpassword'])) { include('db.php'); //I am using passwordu instead of password. $query = "SELECT * FROM users WHERE username = '".$_REQUEST['username']."' AND passwordu = '".md5($_REQUEST['userpassword'])."'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows == 1) { echo "Congratulations. You are now Logged in. You will be logged out when the Browser is closed."; $_SESSION['logval'] = TRUE; } else { echo "You Have Entered Wrong Information. <b>Please Try AGAIN."; } ?> PHP: Any help on why this code is not working, shall be greatly appreciated.
Mhh.. Well, you could start by checking if you really get the data which you need meaning is the entered username - $_REQUEST['username'] correct? is the entered password - $_REQUEST['userpasswird'] and the generated MD5 hash correct? Is the MD5 hashed password in your database, or is it in plain text? Is the $query right? I somehow have the feeling that the MD5 is causing the problem Also: I see that one curly brace is missing at the end of the provided code. It's probably a copy-paste error, right?
You can also do echo before your actual statement ($query). That will print the executed statement on the page. Copy that statement and paste in phpmyadmin on your database. and run their. See if it throws any error their. It will most probably show you the error in there.
What is the purpose of using $_REQUEST instead of $_POST if you know you are working with HTTP POST method ? Are you sure you have a field called passwordu (not password) ? If nothing of this helps, check (simple echo should work) all of your variables before passing them any further.