edit.php 檔案程式碼如下:
<?php
include("./config/conn.php");//內容是連接資料庫相關
$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;script>alert('修改成功,回傳');location.href='txl_list.php';</script>";
}else{
echo "<script>alert('cationhref');lo.hrefrefrefref);lo.href ='txl_list.php';</script>";
}
}
?>
---------------- ------------------------------------------
以上程式碼中:
$sql = "update txl set pid='$pid',name='$name',dept='$dept',phone='$phone',tel='$tel', cre_time='$time' where id='$id'";
把id='$id'"直接指定具體id值是能修改的,不知道為什麼,感覺是取得id值出了問題
--------------------------------------------------------- ---------------------------
修改頁碼如下:
<html>
不吃玉米糖2017-10-25 19:27:41
找到問題所在了,在提交頁面使用了POST提交 <form action="edit.php" method="post">
在接收頁面也應該是POST模式,把$id = $_GET['id']; 改為$id = $_POST['id'];就可以了