Here's the thing.....It is on the same server as a working copy. It is just accessing a different set of tables.
Here are the login and check login files
login.php (not including form and html)
<?php
if (isset($_POST['submit'])) { // if form has been submitted
/* check they filled in what they were supposed to and authenticate */
if(!$_POST['userName'] | !$_POST['password']) {
die('You did not fill in a required field. <a href="login.php" target="_parent">Click here</a> to return to Login.');
}
// authenticate.
if (!get_magic_quotes_gpc()) {
$userName = strtolower(addslashes($_POST['userName']));
$password = sha1(strtolower(addslashes($_POST['password'])));
}else{
$userName = strtolower($_POST['userName']);
$password = sha1(strtolower($_POST['password']));
}
$check = $conn->Execute("SELECT first, userName, password, login_count, access FROM ".$TBEXT."users WHERE userName = '".$userName."'");
if($check->EOF){
die('That Username Does Not Exist In Our System. <a href="login.php" target="_parent">Click here</a> to return to Login.');
}
// check passwords match
$ret_pass = $check->fields[2]->value;
if ($password != $ret_pass) {
die('Incorrect password, please try again.');
}
// if we get here username and password are correct,
//register session variables and set last login time.
$count = $check->fields[3]->value;
$count = $count+1;
$date = date('H:i M d, Y');
$update_login = $conn->Execute("UPDATE ".$TBEXT."users SET login_count='".$count."', last_login = '".$date."' WHERE userName = '".$userName."'");
$_POST['userName'] = $userName;
$_SESSION['userName'] = $userName;
$_SESSION['password'] = $password;
$_SESSION['name'] = stripslashes($check->fields[0]->value);
$_SESSION['access']= stripslashes($check->fields[4]->value);
$logged_in = 1;
?>
check_login.php
<?php
ob_start();
if (!isset($_SESSION['userName']) || !isset($_SESSION['password'])) {
$logged_in = 0;
return;
} else {
if(!get_magic_quotes_gpc()) {
$_SESSION['userName'] = addslashes($_SESSION['userName']);
}
// addslashes to session username before using in a query.
$result = @$conn->Execute("SELECT password FROM ".$TBEXT."users WHERE userName = '".$_SESSION['userName']."'") or die('Database Error. Please Try Again');
if($result->EOF){
$logged_in = 0;
unset($_SESSION['userName']);
unset($_SESSION['password']);
unset($_SESSION['access']);
unset($_SESSION['name']);
}
$ret_pass = stripslashes($result->fields[0]->value);
$_SESSION['password'] = stripslashes($_SESSION['password']);
//compare:
if($_SESSION['password'] == $ret_pass) {
// valid password for username
$logged_in = 1;
} else {
$logged_in = 0;
unset($_SESSION['userName']);
unset($_SESSION['password']);
unset($_SESSION['access']);
unset($_SESSION['name']);
// kill incorrect session variables.
}
}
// clean up
unset($ret_pass);
$_SESSION['userName'] = stripslashes($_SESSION['userName']);
?>
The only changes I have made to this from the working copy is the $TBEXT variable which is defined in connect.php as the root name of each table.