|
|
|
สอบถามเรื่องทำ login session ของ php + mysql หน่อยคับ งง มากก |
|
|
|
|
|
|
|
เอา echo ออกครับ
Code (PHP)
@ob_start();
@session_start();
include("../lib/utility.php");
connect_db();
$u = $_REQUEST["u"];
$p = sha1($_REQUEST["p"]);
$ip = $_SERVER["REMOTE_ADDR"];
if(isset($u)){
if(!isset($u) and !isset($p)){
echo "<img src='image/warned.gif'><font color='#FF0000'>คุณไม่ได้กรอกชื่อผู้ใช้ หรือรหัสผ่าน</font>";
}else{
$sql_chk1 = "select count(user_id) as cou from tb_xuserx where user_user = '$u'";
$rel_chk1 = mysql_query($sql_chk1) or die(mysql_error());
$row_chk1 = @mysql_fetch_array($rel_chk1);
$chk_u = $row_chk1["cou"];
if($chk_u == 0){
echo "<img src='image/warned.gif' ><font color='#FFCC00'>ไม่มีชื่อผู้ใช้นี้ในระบบ..กรุณาอย่าพยายามเข้าใช้งานระบบ</font>";
}else{
$sql_chk2 = "select * from tb_xuserx where user_user = '$u'";
$rel_chk2 = mysql_query($sql_chk2) or die(mysql_error());
$row_chk2 = @mysql_fetch_array($rel_chk2);
$u_in = $row_chk2["user_user"];
$p_in = $row_chk2["user_pass"];
$level_in = $row_chk2["user_level"];
$id_ = $row_chk2["user_id"];
if($u_in != $u and $p_in != $p){
echo "<img src='image/warned.gif' ><font color='#FFCC00'>ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง..กรุณาลองอีกครั้ง</font>";
}else{
$_SESSION["name_full_sup"] = $row_chk2["user_name"].$row_chk2["user_surname"];
$_SESSION["username_in_sup"] = $u_in;
$_SESSION["level_sup"] = $level_in;
$_SESSION["id_sup"] = $id_;
if($_SESSION["username_in_sup"] != ""){
echo"<script>window.location='dashboard.php';</script>";
}else{
echo "<img src='image/warned.gif' ><font color='#FFCC00'>กรุณาล็อกอินใหม่..</font>";
}
}
}
}
}
|
|
|
|
|
Date :
2014-01-29 16:48:01 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|