|
|
|
เกี่ยวกะ login ครับ....จะทำยังไงให้ login life time ครับ หรือกำหนดได้ว่า login กี่วัน |
|
|
|
|
|
|
|
ใช้ field ใน Table เก็บ status ครับ แล้วให้ Sign out จาก ปุ่มที่กำหนด
|
|
|
|
|
Date :
2010-07-15 13:24:09 |
By :
<- Pp -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอละเอียดกว่านี้ครับ
หุห
โค้ดด้วยก็ดีครับ
|
|
|
|
|
Date :
2010-07-15 13:31:03 |
By :
เด็กโง่ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ cookie ครับ กับหนดเป็นวินาที
$week_sec = 3600*24*7;
setcookie('uname', 'member', $week_sec);
setcookie('upass', '1234', $week_sec);
เวลาตรวจสอบก็แค่ใช้ $_COOKIE['uname'], $_COOKIE['upass'] ไปเช็คดูกับ db ครับ
http://gunner.freetzi.com
|
|
|
|
|
Date :
2010-07-15 14:12:16 |
By :
pjgunner |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือ code ผมประมาณนี้อ่ะครับ check login
Code (PHP)
<?
session_start();
include('config.inc.php');
$user =$_POST['user'];
$password =$_POST['password'];
if(empty($user))
{
echo "<script>alert('Please input your username');window.location = 'home.php';</script>";
exit();
}
if(empty($password))
{
echo "<script>alert('Please input your password');window.location = 'home.php';</script>";
exit();
}
$sql = "select *from userin where logname='$user' and pw='$password'";
$result = mssql_query($sql);
$num_rows=mssql_num_rows($result);
if($num_rows==1)
{$_SESSION['admin'] = $user;
header("location:loginpass.php");
exit();
}
else
{echo "<script>alert('Login Fail !!');window.location = 'home.php';</script>";
header("location:home.php");
}
?>
แล้วผมต้องแทรกไรตรงไหนยังไง
พอจะบอกได้มั้ยครับ
แนวทางก็ได้ครับ
ขอบคุณครับ
|
|
|
|
|
Date :
2010-07-15 16:23:45 |
By :
เด็กโง่ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2010-07-15 20:49:00 |
By :
เด็กโง่ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอคำอธิบายหน่อยได้มั้ยครับ
set cookie แล้ว มี cookie แล้ว
แล้วเช็คไรยังไงครับ
แล้วปิดหน้าเวบแล้วเปิดใหม่ก็ยังล็อกอินอยู่
อธิบายการทำงานของมันให้หน่อยครับ
ขอบคุณครับ
|
|
|
|
|
Date :
2010-07-15 21:38:45 |
By :
เด็กโง่ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|