define(array(template => 'login.html')); DrawHeader(); DrawSideMenu(); #DrawLikeBox(); $tpl->assign(array(VAR_FROM_QUERY => $_q)); $tpl->assign(array(VAR_FROM_PAGE => strtolower($_from))); $tpl->assign(array(VAR_INFORM_MESSAGE => NULL)); $tpl->assign(array(VAR_USERNAME => $username)); // Member Zone ... if ($_POST["action"] == "Login") { $username = strtolower(trim($username)); $password = trim($password); $sql = "SELECT * FROM member_tbl WHERE username = '$username' AND password = '$password' "; $rs = $ado->Execute($sql); if ($rs->RecordCount() > 0) { $memberObj = $rs->FetchObject(); if (($memberObj->USERNAME == $username) && ($memberObj->PASSWORD == $password) && ($memberObj->STATUS == "A")) { $memberId = $memberObj->ID; $memberUsername = stripslashes($memberObj->USERNAME); $memberName = stripslashes($memberObj->FULLNAME); $memberEmail = stripslashes($memberObj->EMAIL); $memberLastLogin = $memberObj->LASTLOGIN; session_register("memberId"); session_register("memberUsername"); session_register("memberName"); session_register("memberEmail"); session_register("memberLastLogin"); UpdateField("member_tbl", "lastlogin", date("Y-m-d H:i:s"), "id='$memberObj->ID'"); if ($ado) $ado->Close(); if ($db) $db->Close(); if ($_POST["_from"] == "home") echo ""; elseif ($_POST["_from"] == "about-us") echo ""; elseif ($_POST["_from"] == "air-cond") echo ""; elseif ($_POST["_from"] == "products") { if (empty($_q)) echo ""; else echo ""; } elseif ($_POST["_from"] == "product") echo ""; elseif ($_POST["_from"] == "air-cond-service") echo ""; elseif ($_POST["_from"] == "freezer-service") echo ""; elseif ($_POST["_from"] == "cctv-service") echo ""; elseif ($_POST["_from"] == "member-profile") echo ""; elseif ($_POST["_from"] == "member-password") echo ""; elseif ($_POST["_from"] == "how-to-pay") echo ""; elseif ($_POST["_from"] == "free-installation") echo ""; elseif ($_POST["_from"] == "our-installations") echo ""; elseif ($_POST["_from"] == "installation") echo ""; elseif ($_POST["_from"] == "contact-us") echo ""; else echo ""; } else { $tpl->assign(array(VAR_INFORM_MESSAGE => "ชื่อสมาชิกนี้ ยังไม่ได้รับสิทธิ์เข้าสู่ระบบ")); } } else { $tpl->assign(array(VAR_INFORM_MESSAGE => "ชื่อสมาชิก หรือ รหัสผ่าน ไม่ถูกต้อง")); } } elseif ($_GET["action"] == "Logout") { session_unregister("memberId"); session_unregister("memberUsername"); session_unregister("memberName"); session_unregister("memberEmail"); session_unregister("memberLastLogin"); # session_destroy(); # echo ""; } // End of Member Zone ... if ($ado) $ado->Close(); if ($db) $db->Close(); DrawFooter(); $tpl->parse(TEMPLATE, "template"); $tpl->FastPrint(TEMPLATE); ?>