作为客户,我在显示我的详细信息/个人资料方面没有任何问题,但即使我点击了"保存"我也无法更新/编辑我的个人资料。按钮。我在这里错过了什么吗?
edit_customer_profile.php
<?php
header('Content-Type: text/html; charset=utf-8');
include 'connection.php';
session_start();
if(isset($_SESSION['CustomerID'])) {
$customerID = $_SESSION['CustomerID'];
$customername = $_SESSION['CustomerName'];
$customers = mysql_query("select * from customer where CustomerID='".$customerID."'");
$customer = mysql_num_rows($customers);
if($customer== 1){
$row = mysql_fetch_assoc($customers);
$email = $row['CustomerEmail'];
$contactno = $row['CustomerContactNo'];
$class = $row['CustomerClass'];
$campus = $row['CustomerCampus'];
$intake = $row['CustomerIntake'];
if(isset($_POST['submit'])){
$_var1 = $_POST['new_name'];
$_var2 = $_POST['new_email'];
$_var3 = $_POST['new_contactno'];
$_var4 = $_POST['new_campus'];
$_var5 = $_POST['new_intake'];
$_var6 = $_POST['new_class'];
$query1 = "UPDATE customer
SET CustomerName='$_var1', CustomerEmail='$_var2', CustomerContactNo='$_var3', CustomerCampus='$_var4', CustomerIntake='$_var5', CustomerClass='$_var6'
WHERE CustomerID='$customerID'";
}
}
}
?>
以下是表格
<form method = "post" action=">
<tr>
<td width="170">Name:</td>
<td><input type="text" name="new_name" size="30" value="<?php echo $customername ?>" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="new_email" size="30" value="<?php echo $email ?>" /></td>
</tr>
<tr>
<td>Contact No:</td>
<td><input type="text" name="new_contactno" size="30" value="<?php echo $contactno ?>" /></td>
</tr>
<tr>
<td>Campus:</td>
<td><input type="text" name="new_campus" size="30" value="<?php echo $campus ?>" /></td>
</tr>
<tr>
<td>Intake:</td>
<td><input type="text" name="new_intake" size="30" value="<?php echo $intake ?>" /></td>
</tr>
<tr>
<td>Class:</td>
<td><input type="text" name="new_class" size="30" value="<?php echo $class ?>" /></td>
</tr>
<tr>
<td align="right"><input type="submit" size="30" name="submit" value="Save" /></td>
</tr>
</form>
答案 0 :(得分:1)
您尚未运行更新查询。
使用
运行更新查询$query1 = "UPDATE customer
SET
CustomerName='$_var1',
CustomerEmail='$_var2',
CustomerContactNo='$_var3',
CustomerCampus='$_var4',
CustomerIntake='$_var5', CustomerClass='$_var6'
WHERE CustomerID='$customerID'";
mysql_query($query1);
注意:使用mysqli_ *或pdo_ *函数代替mysql_函数,这将被弃用。