|
 |
|
รบกวนพี่ๆช่วยดูให้หน่อยค่ะ...น้องสงสัยอย่างแรง เป็นโค้ดแก้ไขข้อมูลสมาชิกอะค่ะ ตอนแก้ไขข้อมูลแล้วสามารถแก้ไขได้ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
$host = "localhost";
$username ="root";
$password ="123";
$dbname = "dbwbi";
mysql_connect($host,$username,$password)or die("ไม่สามารถติดต่อ my sql ได้");;
mysql_select_db("$dbname")or die("ไม่สามารถติดต่อฐานข้อมูลได้");
mysql_query("SET NAMES tis620");
?>
Code (PHP)
<form id="form1" name="form1" method="post" action="edituser_save.php">
<table width="98%" height="298" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="32%" scope="row"><div align="left">user(ชื่อผู้เข้าใช้):</div></th>
<td width="68%"><label>
<input type="text" name="txtusername" size=30 maxlength=12 value="<? echo $_SESSION['txtusername']; ?>" >
<input type="button" name="btchuser" value="ตรวจสอบชื่อผู้ใช้" />
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">password:</div></th>
<td><label>
<input type="password" name="txtpassworda" value="<? echo $_SESSION['pass']; ?>" />
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">ยืนยัน password:</div></th>
<td><input type="password" name="txtconpassword" value="" <? echo $_SESSION['pass']; ?>" />
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">ชื่อ:</div></th>
<td><label>
<input type="text" name="txtname" value="<? echo $_SESSION['name']; ?>"/>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">นามสกุล:</div></th>
<td><label>
<input type="text" name="txtlastname" value="<? echo $_SESSION['sname']; ?>"/>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">เพศ:</div></th>
<td><label>
<input name="rdsex1" type="radio" value="1" <? if ($_SESSION['sex']==1) {echo 'checked';}?>/>
ชาย
<input name="rdex2" type="radio" value="2" <? if ($_SESSION['sex']==2) {echo 'checked';}?>/>
หญิง</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">อายุ:</div></th>
<td><label>
<select name="selectage">
<option value="0">เลือกอายุ</option>
<option value="1" <? if ($_SESSION['age']==1) {echo 'selected';}?>>อายุ10-12ปี</option>
<option value="2" <? if ($_SESSION['age']==2) {echo 'selected';}?>>อายุมากกว่า 13 ปี</option>
</select>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">การศึกษา:</div></th>
<td><label>
<input name="rdstudy1" type="radio" value="1" <? if ($_SESSION['study']==1) {echo 'checked';} ?>/>
ผู้เรียนชั้นประถมศึกษาปี่ที่ 5
<input name="rdstudy2" type="radio" value="2" <? if ($_SESSION['study']==2) {echo 'checked';}?>/>
ผู้เรียนทั่วไป
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">E-mail:</div></th>
<td><label>
<input type="text" name="txtemail" maxlength='50' value="<? echo $_SESSION['email']; ?>"/>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">คำถามกันลืม:</div></th>
<td><label>
<select name="select">
<option value="0">เลือกคำถามที่ต้องการ</option>
<option value="1"<? if ($_SESSION['ques']==1) {echo 'selected';}?>>ชื่อเล่น</option>
<option value="2" <? if ($_SESSION['ques']==2) {echo 'selected';}?>>สีที่ชอบ</option>
<option value="3" <? if ($_SESSION['ques']==3) {echo 'selected';}?>>สัตว์เลี้ยงที่ชอบ</option>
</select>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">คำตอบ:</div></th>
<td><label>
<input type="text" name="txtans" value="<? echo $_SESSION['ans']; ?>"/>
</label></td>
</tr>
<tr>
<th scope="row"> </th>
<td><label>
<input type="hidden" name="userid" value="<?=$_GET[id];?>">
<input type="submit" name="btsubmit" value="ตกลง" />
<input type="reset" name="btcancle" value="ยกเลิก" />
</label></td>
</tr>
</table>
</form>
Code (PHP)
<?
include ("connectdb.php");
$strSQL = "UPDATE tbluser SET ";
$strSQL .="username = '".$_POST["txtusername"]."' ";
$strSQL .=",password = '".$_POST["txtpassworda"]."' ";
$strSQL .=",name = '".$_POST["txtname"]."' ";
$strSQL .=",surname = '".$_POST["txtlastname"]."' ";
$strSQL .=",ques = '".$_POST["select"]."' ";
$strSQL .=",email= '".$_POST["txtemail"]."' ";
$strSQL .=" WHERE user_id = '".$_POST["userid"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "<br><a href=mainlessont.php>แก้ไขข้อมูลเรียบร้อยค่ะ.........</a>";
}else{
echo "ข้อมูลผิดพลาดกรุณาตรวจสอบใหม่อีกครั้งค่ะ";
echo "<br><a href=edituser.php>กลับ</a>";
}
?>
|
 |
 |
 |
 |
Date :
2010-01-24 19:55:23 |
By :
kennyg |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|