Hello Everyone,
I have a script that I'm writing for a member's only section of my website. I've been writting and testing the script locally on my computer so that I can minimize errors once it's on the server. My computer is running Win 2000 Pro, IIS, CGI version of PHP v.4.3.2. My script is working fine on this computer, and giving me exactly the results I expected, that is it registers the session variables and allows me to move on to the appropriate sections. My hosting company's server is a Windows 2000 machine, running the CGI version of PHP v.4.3.0, but the script instead goes into a condition that I have if the query didn't return anything. Too see the phpinfo for the server, please visit, http://www.elluminata.com/php/phpinfo.php.
The code that I am using:
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$db = odbc_connect("db", "", "") or die("Couldn't connect to database.");
// Get the user's input from the form
$name = addslashes($POST['name']);
$password =md5($POST['pass']);
// Query the database to see if the username is present
$query = "SELECT count(id) FROM users where password='$password' AND username='$name'";
$result = odbc_exec($db, $query);
$num = odbc_result($result, 1);
echo $num;
if(!$num) {
// When the Query didn't return anything return user to the login form
// Will be implemented later
echo "Didn't work";
} else {
// Start the login session
$SESSION['name']=$name;
$SESSION['pass']=$password;
// Display the sssion information:
echo "Yes it worked!";
}
When I take the condition out in the query statement, the code works, but unfortunately not the way I want it (i.e. authenticating against username and password). If there is any suggestions about what is wrong I would really appreciate it.