|
 |
|
รบกวนดู CODE ให้หน่อยครับ. คือผม..เอาไว้ส่วนบนสุดในหน้า index.php แล้วพอจะรัน...มันจะ alert ไม่พบชื่อผู้ใช้งาน ตลอดเลยครับ... รบกวน ดู CODE ให้หน่อยครับ... |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$subMit=$_POST["subMit"]; // ค่าที่ส่งมาตอนเรา login
if($subMit=="login"){ // แค่นี้ก็หน้าจะได้แล้วครับ
mysql_connect("localhost","root","123456");
mysql_select_db("condo");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM member WHERE Username = '".$_SESSION['Username']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
$sql = "SELECT * FROM member WHERE username = '$username' AND password = '$password' ";
$result = mysql_query($sql);
$num = mysql_num_rows($result); //นับว่าในฐานข้อมูลมีกี่แถวที่มี username = '$username' และ password = '$password'
if($num==1) //พบ username = '$username' และ password = '$password' จำนวน 1 แถว ให้เอาข้อมูลเก็บลง session
{
$_SESSION["user"] = $username;
?>
<script>
alert('ยินดีต้อนรับเข้าสู่ระบบค่ะ');
window.location='user_page.php';//ส่วนนี้อยากให้มันไปหน้าไหนก็ใส่ พาทไฟล์เอา
</script>
<?PHP } else { ?>
<script>
alert('ไม่พบชื่อผู้ใช้งาน $username');
window.location='index.php';//เวลาล็อกอินไม่ถูกก็ให้มันกลับมาหน้าแรก
</script>
<?PHP
}
}
?>
|
 |
 |
 |
 |
Date :
2012-07-11 18:11:54 |
By :
Kill1430 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
echo $sql;
$result = mysql_query($sql);
เอาค่า SQL ออกมาดูครับ จากนั้นก็เอาไปรันทดสอบใน phpMyAdmin ดูว่ามันมี Record หรือไม่ครับ
|
 |
 |
 |
 |
Date :
2012-07-11 21:06:35 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ..ขอบคุณครับ...
|
 |
 |
 |
 |
Date :
2012-10-16 19:42:32 |
By :
chak.jakkree |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|