<? $no_edit=$_GET['no_edit']; include"connect.php"; $tblname="user"; $sql="select *from $tblname where no='$no_edit'"; $dbquery=mysql_db_query($dbname,$sql); $result=mysql_fetch_array($dbquery); $user=$result['user']; $pass=$result['pass']; $type=$result['type']; ?> <form id="form1" name="form1" method="post" action="check_user_edit.php"> <table width="536" border="0" align="center"> <tr> <td width="135" align="center">Username</td> <td width="135" align="center">Password</td> <td width="135" align="center">ประเภทผู้ใช้งาน</td> <td width="102" align="center"><input name="no_edit" type="hidden" id="no_edit" value="<?= $no_edit ?>" /></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input name="user" type="text" id="user" value="<? echo $user; ?>" size="15" /></td> <td align="center" bgcolor="#FFFFFF"><input name="pass" type="text" id="pass" value="<? echo $pass; ?>" size="15" /></td> <td align="center" bgcolor="#FFFFFF"><select name="type" id="type"> <option value="" <?php if (!(strcmp("", $type))) {echo "selected=\"selected\"";} ?>>-------------------</option> <option value="ผู้ใช้งานทั่วไป" <?php if (!(strcmp("ผู้ใช้งานทั่วไป", $type))) {echo "selected=\"selected\"";} ?>>ผู้ใช้งานทั่วไป</option> <option value="หัวหน้าแผนก" <?php if (!(strcmp("หัวหน้าแผนก", $type))) {echo "selected=\"selected\"";} ?>>หัวหน้าแผนก</option> <option value="ผู้ดูแลระบบ" <?php if (!(strcmp("ผู้ดูแลระบบ", $type))) {echo "selected=\"selected\"";} ?>>ผู้ดูแลระบบ</option> </select></td> <td bgcolor="#FFFFFF"><label for="type"> <input type="submit" name="submit" id="submit" value="บันทึก" /> <input type="button" onclick="window.location='admin.php'" value="ยกเลิก"> </label></td> </tr> </table> </form>
<? include"connect.php"; $tblname="user"; $no_edit=$_POST['no_edit']; $user=$_POST['user']; $pass=$_POST['pass']; $type=$_POST['type']; if((empty($user))||(empty($pass))||(empty($type)) ){ echo "<script>alert('กรุณากรอกให้ครบ');history.back();</script>"; exit(); }else{ $sql = "select * FROM $tblname where (user='".$user."' ) "; $query = mysql_query($sql); $num=mysql_num_rows($query); if(mysql_num_rows($query) != 0){ echo "<script>alert('ขออภัย!! ท่านไม่สามารถใช้ชื่อ $user ได้');history.back();</script>"; exit(); }else{ $sql_update = "update $tblname set user='$user',pass='$pass',type='$type' WHERE no ='$no_edit' "; $result_update= mysql_query($sql_update) or die ("<script>alert('ไม่สามารถแก้ไขข้อมูลได้');history.back();</script>"); echo "<script>alert('แก้ไขข้อมูลเรียบร้อยแล้ว');window.location='admin.php';</script>"; exit(); } } mysql_close(); ?>
<form id="form1" name="form1" method="post" action="check_add_user.php" onsubmit="javascript:return fncSubmit();"> <table width="594" border="0" align="center"> <tr> <td width="775" height="175" align="center" bgcolor="#FFFFFF"><p> <label for="user"></label> </p> <table width="525" height="20" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="135" height="20" align="center">Username</td> <td width="135" align="center">Password</td> <td width="135" align="center">ประเภทผู้ใช้งาน</td> <td width="102"> </td> </tr> <tr> <td height="20" align="center" bgcolor="#FFFFFF"><input name="user" type="text" id="user" size="15" /></td> <td align="center" bgcolor="#FFFFFF"><input name="pass" type="text" id="pass" size="15" /></td> <td align="center" bgcolor="#FFFFFF"><select name="type" id="type"> <option>-------------------</option> <option value="ผู้ใช้งานทั่วไป">ผู้ใช้งานทั่วไป</option> <option value="หัวหน้าแผนก">หัวหน้าแผนก</option> <option value="ผู้ดูแลระบบ">ผู้ดูแลระบบ</option> </select></td> <td align="left"><input type="submit" name="submit" id="submit" value="เพิ่ม" /> <input type="reset" name="Reset" id="button" value="รีเซ็ต" /></td> </tr> </table> <table width="527" border="1"> <tr> <td width="38" align="center">ลำดับ</td> <td width="120" align="center">ชื่อผู้ใช้งาน</td> <td width="120" align="center">รหัสผ่าน</td> <td width="125" align="center">ประเภทผู้ใช้</td> <td width="42" align="center">แก้ไข</td> <td width="42" align="center">ลบ</td> </tr> <tr> <? while($result=mysql_fetch_array($dbquery)){ ?> <td height="26" align="center"><?= $result[no]; ?></td> <td align="center"><label for="user"><?= $result[user]; ?></label></td> <td align="center"><label for="pass"></label><?= $result[pass]; ?></td> <td align="center"><label for="type"></label><?= $result[type]; ?></td> <? } ?> </table></td> </tr> </table> </form>
<? $No = 1; //ตัวอย่างนี้ใช้ได้แค่หน้าแรกถ้ามีการสร้างฟังก์ชันแบ่งหน้าคุณต้องใส่เงื่อนไขด้วย while($result=mysql_fetch_array($dbquery)){ ?> <td height="26" align="center"><?= $No?></td> <td align="center"><label for="user"><?= $result[user]; ?></label></td> <td align="center"><label for="pass"></label><?= $result[pass]; ?></td> <td align="center"><label for="type"></label><?= $result[type]; ?></td> <? $No++; } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง