|
 |
|
รบกวน ถามเรื่อง คำสั่ง qsl update กรอกตาม ฟิล แล้ว แต่ไม่เข้าฐานข้อมูล ไคช่วยได้ ช่วยทีคับ |
|
 |
|
|
 |
 |
|
หน้า ฟอร์ม
Code (PHP)
<?
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
mysql_connect("localhost","root","1234");
mysql_select_db("hotel");
mysql_query("set names utf8");
$strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION['UserID']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html >
<head>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveupdatemember.php">
<table width="524" border="0" align="center">
<tr>
<td width="143" align="right">Username :</td>
<td width="371"> <input name="txtUsername" type="text" disabled id="txtUsername" value="<?=$objResult["Username"];?>"></td>
</tr>
<tr>
<td align="right">Password :</td>
<td><input name="txtPassword" type="password" id="txtPassword" value="<?=$objResult["Password"];?>"></td>
</tr>
<tr>
<td align="right">Confirm Password :</td>
<td><input name="txtConPassword" type="password" id="txtConPassword" value="<?=$objResult["Password"];?>"></td>
</tr>
<tr>
<td align="right">ชื่อ :</td>
<td><input name="txtName" type="text" id="txtName" value="<?=$objResult["Name"];?>"></td>
</tr>
<tr>
<td align="right">นามสกุล :</td>
<td><input name="txtName" type="text" id="txtName" value="<?=$objResult["Surname"];?>"></td>
</tr>
<tr>
<td align="right">เบอร์โทรศัพท์ :</td>
<td><input name="txtName" type="text" id="txtName" value="<?=$objResult["Tel"];?>"></td>
</tr>
<tr>
<td align="right" valign="top">ที่อยู่ :</td>
<td><textarea name="txtAddress" cols="45" rows="5" id="txtAddress"><?=$objResult["Address"];?>
</textarea></td>
</tr>
<tr>
<td align="right">E-mail :</td>
<td><input name="txtEmail" type="text" id="txtEmail" value="<?=$objResult["Email"];?>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="แก้ไข" />
<input type="reset" name="button2" id="button2" value="ยกเลิก" /></td>
</tr>
</table>
</form></td>
</tr>
</body>
</html>
หน้า saveupdate.php
Code (PHP)
<?
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
mysql_connect("localhost","root","1234");
mysql_select_db("hotel");
if($_POST["txtPassword"] != $_POST["txtConPassword"])
{
echo "Password not Match!";
exit();
}
$no = $_SESSION['no'];
$user = $_POST["txtUsername"];
$pass =$_POST['txtPassword'];
$name = $_POST["txtName"];
$surname= $_POST["txtSurname"];
$address = $_POST["txtAddress"];
$tel = $_POST["txtTel"];
$email = $_POST["txtEmail"];
$sql = "UPDATE member SET ";
$sql .= "Username='$user',
Password='$pass',
Name='$name',
Surname='$surname',
Address='$address',
Tel='$tel',
Email='$email'
WHERE UserID='$no'";
$objQuery =mysql_query($sql) ;
echo "<br>";
if($_SESSION["Status"] == "ADMIN")
{
echo "<script>
alert('แก้ไขเรียบร้อย');
window.location='admin_page.php';
</script>";
}
else
{
echo "<script>
alert('แก้ไขเรียบร้อย');
window.location='user_page.php';
</script>";
}
mysql_close();
?>
เรา เซต ค่าแล้ว ทำไหม ไม่เข้า ฐานข้อมูลอ่ะคับ หมายถึง แก้ไขข้อมูลไม่ได้ งง มาก
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2011-10-04 22:44:50 2011-10-04 22:45:24 2011-10-04 22:46:21
|
 |
 |
 |
 |
Date :
2011-10-04 22:43:47 |
By :
usakira |
View :
685 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัดที่ 16 ไฟล์ saveupdate.php
$no = $_SESSION['no'];
แก้เป็น
Code (PHP)
$no = $_SESSION['UserID'];
|
 |
 |
 |
 |
Date :
2011-10-05 08:18:35 |
By :
nimporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ มักๆๆๆๆๆ เลยคับ
|
 |
 |
 |
 |
Date :
2011-10-05 11:07:32 |
By :
usakira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|