|
|
|
ช่วยที่คับ ผม งง มากเลยคับ PHP กับ MySQLi มันควรจะแก้ไข อย่างไรคับ |
|
|
|
|
|
|
|
ขอบคุณคับผม
|
|
|
|
|
Date :
2016-02-25 23:51:09 |
By :
comsai2537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start();
$serverName = "localhost";
$userName = "root";
$userPassword = "root";
$dbName = "mydatabase";
$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$strSQL = "SELECT * FROM member WHERE Username = '".mysqli_real_escape_string($objCon,$_POST['txtUsername'])."'
and Password = '".mysqli_real_escape_string($objCon,$_POST['txtPassword'])."'";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = mysqli_fetch_array($objQuery,MYSQLI_ASSOC);
if(!$objResult)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $objResult["UserID"];
$_SESSION["Status"] = $objResult["Status"];
session_write_close();
if($objResult["Status"] == "ADMIN")
{
header("location:admin_page.php");
}
else
{
header("location:user_page.php");
}
}
mysqli_close($objCon);
?>
|
|
|
|
|
Date :
2016-02-26 09:35:13 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|