<?php
if(isset($_POST['submit'])&& $_POST['submit'])
{
$UID=$_GET['ID'];
$name=$_POST['uname'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$servername="localhost";
$username = "root";
$password = "";
$dbname = "records";
// 創建連接
$conn = new mysqli($servername, $username, $password, $dbname);
// 檢測連接
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);}
$sql="UPDATE user SET u_name=$name,u_phone=$phone,u_email=$email WHERE id='$UID'";
if(mysqli_query($conn,$sql)){
echo "修改成功!";}
else{
echo"修改失敗!";}
mysqli_close($conn);
echo'<meta http-equiv="refresh" content="2;url=empManage.php">';
}
?>
1.你所謂的失敗是沒有改掉你想要改的數據吧.先檢查一下?UID的值對不對,未必是執行錯誤,可能是條件錯誤
2.在你的UPDATE裡。$name,$phone,$email,前後都缺少單引號