|
 |
|
ขอคำแนะนำเกี่ยวการล็อกอินด้วยค่ะ ว่าทำไมเมื่อเพิ่มการทำลาย session ในไฟล์ล็อกเอาท์ พอมาล็อกอินใหม่ต้องล็อกอินสองครั้งถึงจะผ่าน |
|
 |
|
|
 |
 |
|
หลัง Login น้องก็ echo ค่าใน Session ดูน่ะครับ ว่ามันมีหรือเปล่า
|
 |
 |
 |
 |
Date :
2012-05-20 06:50:33 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo ดูแล้วค่ะ และแสดงผลดังรูป

จากผลที่ echo ออกมาจะมีการส่งค่าของ "กรุณาตรวจสอบชื่อผู้ใช้และรหัสผ่าน" ซึ่งอันนี้จะอยู่ในส่วนของนักศึกษา ทำไมต้องมีการส่งค่านี้มาด้วยค่ะ ไม่เข้าใจ ใครอธิบายได้ไหมค่ะ
Code (PHP)
<?session_start();
include("nusoap/nusoap.php");
include ("connect_db.php");
$txtUsername=$_POST['txtUsername'];
$txtPassword=$_POST['txtPassword'];
$strSQL = "SELECT * FROM OFFICER WHERE USERNAME = '".trim($_POST['txtUsername'])."' and PASSWORD = '".trim($_POST['txtPassword'])."'";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$objResult = oci_fetch_array($objParse,OCI_BOTH);
//$type_id=$row["type_id"];
$OFFICERID=$objResult["OFFICERID"];
if ($objResult)
{$_SESSION["OFFICERID"] = $objResult["OFFICERID"];
$_SESSION["OFFICERNAME"] = $objResult["OFFICERNAME"];
$_SESSION["OFFICERSURNAME"] = $objResult["OFFICERSURNAME"];
$_SESSION["type_id"] = $objResult["type_id"];
if ($type_id== '1')
{
echo "<meta http-equiv='refresh' content='50;URL=index1.php'>";
//header("location:index1.php");
session_write_close(); //¨º¡ÒÃÊÃéÒ§ session //
}
else if ($type_id== "2")
{
echo "<meta http-equiv='refresh' content='50;URL=index_officer.php'>";
//header("location:index_officer.php");
session_write_close(); //¨º¡ÒÃÊÃéÒ§ session //
}
else if ($type_id== "3")
{
echo "<meta http-equiv='refresh' content='50;URL=index_officer1.php'>";
//header("location:index_officer1.php");
session_write_close(); //¨º¡ÒÃÊÃéÒ§ session //
}
}else{
/*echo"<script language='JavaScript'>";
echo"alert('ª×èÍáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ');";
echo"</script >";
echo "<meta http-equiv='refresh' content='0;URL=login_admin.php'>";*/
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$client = new nusoap_client('http://webservice.yru.ac.th/server/ns_getstudent.php?wsdl', true);
$result= $client->call('auth', array('username' => $txtUsername,'password' => $txtPassword));
if ($result<>"กรุณาตรวจสอบชื่อผู้ใช้และรหัสผ่าน")
{
$b = explode(",",$result);
$_SESSION["student_code"]= $b[0]; //????????????
$_SESSION["cars_id"]=$b[1]; //???? ???.
$_SESSION["prefix"]=$b[2]; //????????
$_SESSION["std_name"]=$b[3];//????????????
$_SESSION["std_surname"]=$b[4];//???????
$_SESSION["program"]=$b[5];//????????
$_SESSION["faculty"]=$b[6];//???
session_write_close(); //?????????? session //
echo "<meta http-equiv='refresh' content='50;URL=index_std.php?student_code=".$_SESSION["student_code"]."' >";
}else {
echo"<script language='JavaScript'>";
echo"alert('ª×èÍáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ');";
echo"</script >";
echo "<meta http-equiv='refresh' content='50;URL=login_admin.php'>";
//}
}
?>
|
 |
 |
 |
 |
Date :
2012-05-20 08:06:10 |
By :
comerror |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทดลองตามนี้ดูก่อนน่ะครับ แล้วรายงานผลให้ทราบด้วย
Code (PHP)
<? session_start();
include("nusoap/nusoap.php");
include ("connect_db.php");
$txtUsername=$_POST['txtUsername'];
$txtPassword=$_POST['txtPassword'];
$strSQL = "SELECT * FROM OFFICER WHERE USERNAME = '".trim($_POST['txtUsername'])."' and PASSWORD = '".trim($_POST['txtPassword'])."'";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse);
$objResult = oci_fetch_array($objParse,OCI_ASSOC);
//$type_id=$row["type_id"];
$OFFICERID=$objResult["OFFICERID"];
oci_execute ($objParse);
if (oci_fetch_all($objParse,$resultArr) >0 )
{ $_SESSION["OFFICERID"] = $objResult["OFFICERID"];
$_SESSION["OFFICERNAME"] = $objResult["OFFICERNAME"];
$_SESSION["OFFICERSURNAME"] = $objResult["OFFICERSURNAME"];
$_SESSION["type_id"] = $objResult["type_id"];
if ($type_id== '1')
{
echo "<script>window.location='index1.php';</script>";
}
else if ($type_id== "2")
{
echo "<script>window.location='index_officer.php';</script>";
}
else if ($type_id== "3")
{
echo "<script>window.location='index_officer1.php';</script>";
}
}else{
/*echo"<script language='JavaScript'>";
echo"alert('ª×èÍáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ');";
echo"</script >";
echo "<meta http-equiv='refresh' content='0;URL=login_admin.php'>";*/
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$client = new nusoap_client('http://webservice.yru.ac.th/server/ns_getstudent.php?wsdl', true);
$result= $client->call('auth', array('username' => $txtUsername,'password' => $txtPassword));
if ($result<>"?????????????????????????????????")
{
$b = explode(",",$result);
$_SESSION["student_code"]= $b[0]; //????????????
$_SESSION["cars_id"]=$b[1]; //???? ???.
$_SESSION["prefix"]=$b[2]; //????????
$_SESSION["std_name"]=$b[3];//????????????
$_SESSION["std_surname"]=$b[4];//???????
$_SESSION["program"]=$b[5];//????????
$_SESSION["faculty"]=$b[6];//???
//session_write_close(); //?????????? session //
echo "<script>window.location='index_std.php?student_code=".$_SESSION["student_code"]."'</script>";
}else {
echo"<script language='JavaScript'>";
echo"alert('ª×èÍáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ');";
echo "<script>window.location='login_admin.php';</script>";
}
?>
Code (PHP)
<?
session_start();
session_destroy();
?>
<html>
<head>
<title>ออกจากระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?
echo"<script language='JavaScript'>";
echo"alert('ออกจากระบบเรียบร้อย');";
echo "window.location='login_admin.php'; ";
echo "</script >";
exit(0);
?>
</html>
|
ประวัติการแก้ไข 2012-05-21 01:33:59
 |
 |
 |
 |
Date :
2012-05-20 22:41:41 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|