if (isset($_POST["phpAuth_Submit"])) {
//$register_no = "4";
include "phpAuth_config.php";
//include ("phpBase_inc.php");
$filename = $phpBase_register.".".$database_name;
if (!file_exists($filename)) {
echo "No database exists. Please check your config file.";
} else {
$handler = fopen($filename,'r');
$members = file_get_contents($filename);
// get username and password
$users_array = explode ("\n",$members);
foreach ($users_array as $users) {
if ($users != "" || $users != NULL) {
// break username and password string into seperate variables.
list($username,$password) = explode("\t",$users);
if ($_POST["phpAuth_usr"] == trim($username) && md5($_POST["phpAuth_pwd"]) == trim($password)) {
$logged_in = 1;
break;
} else {
$logged_in = 0;
}
} else {
break;
}
} // end foreach
if ($logged_in != 1) { // IF USER IS NOT LOGGED IN
echo "Error! Incorrect Details.
Go Back";
} else { // ELSE LOGGED IN
session_start();
$_SESSION["phpAuth_username"] = $_POST["phpAuth_usr"];
$_SESSION["phpAuth_password"] = $_POST["phpAuth_pwd"];
$_SESSION["phpAuth_register"] = $_POST["phpAuth_reg"];
if ($_POST["phpAuth_rm"] == 1) {
setcookie("phpAuth_username",$_POST["phpAuth_usr"],time()+3600);
}
header('Location: '.$login_redirect.'');
}
} // END IF FILE EXISTS
} else {
?>
}
?>