<?php ob_start(); session_start(); include "connect.php"; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <? $_SESSION['usr']=$_POST["username"]; $pass=$_POST["pass"]; if (($_SESSION['usr']=="")||($pass=="")) { echo "<script>alert('Username หรือ Password ยังไม่ได้กรอก');history.back();</script>"; } $usr = $_SESSION['usr']; $sql = "SELECT * FROM student, WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 1"); $num=mysql_num_rows($result); if ($num>0) { $_SESSION['sta'] = "student"; session_register("username"); echo "<script> window.location ='studentPage.php'; </script>"; } else { $num = 0; $sql = "SELECT * FROM teacher WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 2"); $num=mysql_num_rows($result); if($num>0) { $_SESSION['sta'] = "teacher"; session_register("username"); echo "<script> window.location ='teacherPage.php'; </script>"; } else { $sql = "SELECT * FROM admin WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 3"); $num=mysql_num_rows($result); if($num>0) { $_SESSION['sta'] = "admin"; session_register("username"); echo "<script> window.location ='adminPage.php'; </script>"; } else { echo "<script>alert('Username หรือ Password ไม่ถูกต้อง');history.back();</script>"; } } } ob_end_flush(); mysql_close(); ?>
<?php session_start(); ?>
<?php include "connect.php"; echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> "; ob_start(); session_start(); $_SESSION['usr']=$_POST['username']; $pass=$_POST['pass']; if ($_SESSION['usr'] == "" || $pass == "") { echo "<script>alert('Username หรือ Password ยังไม่ได้กรอก');history.back();</script>"; } $usr = $_SESSION['usr']; $sql = "SELECT * FROM student, WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 1"); $num=mysql_num_rows($result); if ($num > 0) { $_SESSION['sta'] = "student"; session_register("username"); echo "<script> window.location ='studentPage.php'; </script>"; }else{ $num = 0; $sql = "SELECT * FROM teacher WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 2"); $num=mysql_num_rows($result); if($num > 0) { $_SESSION['sta'] = "teacher"; session_register("username"); echo "<script> window.location ='teacherPage.php'; </script>"; }else{ $sql = "SELECT * FROM admin WHERE username = '$usr' and psw = '$pass'"; $result = mysql_query($sql) or die ("Select Error 3"); $num=mysql_num_rows($result); if($num > 0) { $_SESSION['sta'] = "admin"; session_register("username"); echo "<script> window.location ='adminPage.php'; </script>"; }else{ echo "<script>alert('Username หรือ Password ไม่ถูกต้อง');history.back();</script>"; } } } ob_end_flush(); mysql_close(); ?>
Quote:ขอบคุณนะค่ะ ใส่@ตัวเดียวเอง
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง