<?php require_once('Connections/areaConn.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['userName'])) {
$loginUsername=$_POST['userName'];
$password=$_POST['passWord'];
$selectType=$_POST['sele'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "viewList.php";
echo $_POST['sele'];
if($selectType=="3"){
$LoginRS__query=sprintf("SELECT mem_pid,mem_password FROM member2_tb WHERE mem_pid=%s AND mem_password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
}elseif($selectType=="1"){
$LoginRS__query=sprintf("SELECT mem_pid, mem_numposition FROM member_tb WHERE mem_pid=%s AND mem_numposition=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
}elseif($selectType==2){
$LoginRS__query=sprintf("SELECT mem_pid, mem_numposition FROM member3_tb WHERE mem_pid=%s AND mem_numposition=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
}
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_areaConn, $areaConn);
$LoginRS = mysql_query($LoginRS__query, $areaConn) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
$_SESSION['MM_Select']=$selectType;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<html>
<head>
<title>Office of Kamphaengphet Primary Education Area 2</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/login.css" rel="stylesheet" />
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/login.js"></script>
</head>
<body>
<div class="container" >
<div class="row">
<div class="card card-container">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">
<span class="glyphicon glyphicon-user"></span>ลงชื่อเข้าใช้งาน
</h3>
</div>
</div>
<div class="panel-body">
<form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" class="form-signin" name="loginFRM">
<input type="text" class="form-control" name="userName" placeholder="ชื่อผู้ใช้" />
<input type="password" class="form-control" name="passWord" placeholder="รหัสผ่าน" />
<input type="radio" name="sele" value="1" checked="true"> ข้าราชการครู<br>
<input type="radio" name="sele" value="2"> รองผู้อำนวยการ สพท.<br>
<input type="radio" name="sele" value="3" > บุคลากรทางการศึกษาอื่น 38ค.
<button class="btn btn-primary btn-block btn-signin" type="submit" name="Login">เข้าสู่ระบบ</button>
</form>
</div>
<div class="panel-footer" style="text-align:center">
<a href="admin/login.php">สำหรับผู้ดูแลระบบ</a>
</div>
</div>
</div>
</div>
</body>
</html>