PHP Code:
<?php
ob_start();
session_start();
include("../modules/include/Config.php");
require_once("../modules/include/Security.php");
require_once("../modules/include/sqlConn.php");
mssql_select_db($dbName1, $dbConn) or die ("Couln't select database $dbName1");
if(isset($_SESSION['loggedin'])) {
header("location:./../");
} else {
if(isset($_POST['submit'])) {
$check = new security();
$message = null;
if($check->is_secure($_POST['username']) == false) $message[] = "";
if ($check->is_secure($_POST['password']) == false) $message[] = "";
if(count($message) > 0) {
for($i = 0; $i < count($message); $i++) {
print $message[$i];
header("location:./../?invalidData");
}
return;
} else {
$username = $_POST['username'];
$password = md5($_POST['password']);
$verifyAccount = mssql_num_rows(mssql_query("select * from TB_User where StrUserID = '$username' AND password = '$password'"));
if($verifyAccount <= 0) {
header("location:./../?failedLogin");
} else {
$_SESSION['loggedin'] = "YES";
$_SESSION['name'] = $username;
header("location:./../");
}
}
}
}
ob_flush();
?>