<form action="chk.php" method="post"> <fieldset style="width:35%; border-color:#000;"><legend align="center"><font color="#FF0000"><b>เข้าสู่ระบบ</b></font></legend><br /><br /> <table align="center"> <tr> <td align="right"><b>ชื่อผู้ใช้งาน :</b></td> <td align="left"><input type="text" id="username" style="height:35px; font-size:18px"/></td> </tr> <tr><td></td></tr> <tr><td></td></tr> <tr> <td align="right"><b>รหัสผ่าน :</b></td> <td align="left"><input type="text" id="username" style="height:35px; font-size:18px"/></td> </tr> <tr> <td colspan="2" align="center"> <input name="Submit" type="submit" value="เข้าสู่ระบบ" class="button" style="font-size:14px; font-weight:800"> </td> </tr> </table> </fieldset> </form>
<? session_start(); mysql_connect("localhost","root","1234"); mysql_select_db("motor"); $strSQL = "SELECT * FROM user WHERE username = '".mysql_real_escape_string($_POST['username'])."' and password = '".mysql_real_escape_string($_POST['password'])."'"; $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); if(!$objResult) { echo "Username and Password Incorrect!"; } else { $_SESSION["user_id"] = $objResult["user_id"]; $_SESSION["user_type"] = $objResult["user_type"]; session_write_close(); if($objResult["user_type"] == "1") { header("location:index_admin.php"); } else if($objResult["user_type"] == "2") { header("location:index_store.php"); } else if($objResult["user_type"] == "3") { header("location:index_purchase.php"); } else { header("location:index_spare.php"); } } mysql_close(); ?>
$strSQL = "SELECT * FROM user WHERE username = '".mysql_real_escape_string($_POST['username'])."' and password = '".mysql_real_escape_string($_POST['password'])."'"; echo $strSQL;
<form action="chk.php" method="post"> <fieldset style="width:35%; border-color:#000;"><legend align="center"><font color="#FF0000"><b>เข้าสู่ระบบ</b></font></legend><br /><br /> <table align="center"> <tr> <td align="right"><b>ชื่อผู้ใช้งาน :</b></td> <td align="left"><input type="text" id="username" name="username" style="height:35px; font-size:18px"/></td> </tr> <tr><td></td></tr> <tr><td></td></tr> <tr> <td align="right"><b>รหัสผ่าน :</b></td> <td align="left"><input type="text" id="password" name="password" style="height:35px; font-size:18px"/></td> </tr> <tr> <td colspan="2" align="center"> <input name="Submit" type="submit" value="เข้าสู่ระบบ" class="button" style="font-size:14px; font-weight:800"> </td> </tr> </table> </fieldset> </form>
<? session_start(); mysql_connect("localhost","root","1234"); mysql_select_db("motor"); $username=mysql_real_escape_string($_POST['username']); $password=mysql_real_escape_string($_POST['password']); $strSQL = "SELECT * FROM user WHERE username = '".$username."' and password = '".$password."'"; $objQuery = mysql_query($strSQL) or die (mysql_error()); $objResult = mysql_fetch_array($objQuery); $num_rows=mysql_num_rows($objQuery); if($num_rows == 0) { echo "Username and Password Incorrect!"; } else { $_SESSION["user_id"] = $objResult["user_id"]; $_SESSION["user_type"] = $objResult["user_type"]; session_write_close(); if($objResult["user_type"] == "1") { header("location:index_admin.php"); } else if($objResult["user_type"] == "2") { header("location:index_store.php"); } else if($objResult["user_type"] == "3") { header("location:index_purchase.php"); } else { header("location:index_spare.php"); } } mysql_close(); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง