edit.php file code is as follows:
<?php
include("./config/conn.php");//The content is related to connecting to the database
$id = $ _GET['id'];
$pid = $_POST['pid'];
$name = $_POST['name'];
$dept = $_POST['dept'];
$phone = $_POST['phone'];
$tel = $_POST['tel'];
$time = date("Y-m-d H:i:s");
if( $conn){
$sql = "update txl set pid='$pid',name='$name',dept='$dept',phone='$phone',tel='$tel',cre_time ='$time' where id='$id'";
$que = mysqli_query($conn,$sql);
if($que){
echo "<script>alert(' The modification is successful and returns ');location.href='txl_list.php';</script>";
}else{
='txl_list.php';</script>";
}
}
?>
---------------- ------------------------------------------
The above code Medium:
$sql = "update txl set pid='$pid',name='$name',dept='$dept',phone='$phone',tel='$tel', cre_time='$time' where id='$id'";
The specific id value can be modified by directly specifying id='$id'". I don’t know why, but it feels like the id value is obtained. question
------------------------------------------- --------------------------
Modify the page code as follows:
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="./CSS/style.css">
</head>
<body>
<?php include("header.php");?>
<?php
include("./config/conn.php");
$id = $_GET['id'];
$sql = "select * from txl where id='$id'";
$que = mysqli_query($conn,$sql);
$rw = mysqli_fetch_assoc($que);
?>
<div class="div1">
<form action="edit.php" method="post">
<input type="hidden" name="id" value="<?php echo $rw['pid'];?>">
<p>用户编号:<input type="text" name="pid" value="<?php echo $rw['pid'];?>"></p>
<p>用户姓名:<input type="text" name="name" value="<?php echo $rw['name'];?>"></p>
<p>用户部门:<select id="dept" name="dept">
<option value="<?php echo $rw['dept'];?>"><?php echo $rw['dept'];?></option>
<option name="cwk">财务科</option>
<option name="sjk">审计科</option>
<option name="bwk">保卫科</option>
</select></p>
<p>手机号码:<input type="text" name="phone"value="<?php echo $rw['phone'];?>"></p>
<p>办公电话:<input type="text" name="tel"value="<?php echo $rw['tel'];?>"></p>
<p><input type="submit" value="修改"> <input type="reset" value="重置"></p>
</form>
</div>
<?php include ("footer.html");?>
</body>
</html>
I found the problem. I used POST submission on the submission page <form action="edit.php" method="post">
The receiving page should also be in POST mode, put $id = $_GET['id']; Change to $id = $_POST['id']; That's it
You first output $_GET['id'] in the php file to see if you can get the value, or whether your parameter names are written correctly