Page 1 of 1

form processing code runs in windows but not on linux

Posted: Thu Jan 08, 2009 3:09 am
by ahmedyk
Dear Friends,
The following is form processing code which runs perfectly on windows server but when i try it on Linux Redhat server, it does not authenticate the user although the username and password are correct.
The code :

<?php session_start();

include("config/class.inc");
include("config/errors.inc");

/* prevent empty entries from going beyond this point */

if (strlen(trim($username)) == 0) {
$chronerr->addError(1,"Username");
}



if (strlen(trim($password)) == 0) {
$chronerr->addError(1,"Password");
}



if ($chronerr->error_flag) {
header("location: login.php");
}


$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];


$chrondb = new ChronDB_sql;
$qry_str = "select count(*) from access where username='".$username."' and password='".$password."';";
$chrondb->query($qry_str);
$chrondb->next_record();
$user_row_count = $chrondb->record[0];
if ($user_row_count == 1) {
/* start session mgmt & register session variables */

session_register("loggedin");
$loggedin = true;
$date = date('m d, Y');
$update_login = mysql_query("UPDATE user SET last_login = '$date' WHERE username ='".$username."'");
header("Location: index.php");
}

else {
$chronerr->addError(9,"Login authentication");
header("location: ".$_SERVER['HTTP_REFERER']);
}
?>

Please help me to know why it is not authenticating the user.

Re: form processing code runs in windows but not on linux

Posted: Thu Jan 08, 2009 3:25 am
by requinix
Looks like you're relying on register_globals.

Each variable that's coming from the form needs a line near the top like

Code: Select all

<?php session_start();
 
include("config/class.inc");
include("config/errors.inc");
 
$username = $_POST["username"];
$password = $_POST["password"];
// etc