gpt4 book ai didi

php $_GET 在提交表单后失去值(value),所以我无法使用它更新数据库表

转载 作者:太空宇宙 更新时间:2023-11-03 11:57:31 26 4
gpt4 key购买 nike

这是我尝试更新数据库页面的页面

一切都是正确的,除了在最初提交表单后丢失 $_get 中的值但它丢失了的部分

$active_id=$_GET['client_id'];



$query = "UPDATE clients SET name='$updatedName1',surname = '$updatedSurname', tel1='$updatedTel1', tel2='$updatedTel2', id_num='$updatedTel2',
address='$updatedAddress1' WHERE client_id = '$active_id' ";

这是我从中获取值的页面,

 if ( $name != ''){
echo "<tr>", "<td>", "<a href=\"display_row.php?client_id=$id\">",$id_num, " " ,$name ," ",$surname,"</a>","</td>","</tr>";

echo "<form method ='POST' name = 'update' action='display_row.php'>";
echo "</br>";
echo "</br>";
echo "<th style='color:green' >name</th><th style='color:green'>surname</th>";
echo "<tr >","<td>","<input type ='text' name ='surname' value ='$Fname'>","<td>","<input type ='text' name ='name' value ='$Fsurname'>","</td>","</tr>";
echo "</table>";
echo "</br>";
echo "</br>";
echo "<table>";
echo "<th style='color:green' >Telephone1</th><th style='color:green'>Telephone2</th>";
echo "<tr >","<td>","<input type ='text' name ='tel1' value ='$Ftel1' >","<td>","<input type ='text' name ='tel2' value ='$Ftel2'>","</td>","</tr>";
echo "<table>";
echo "<tr>","<td>","<label style='color:green'>Id No: ","</td>","</tr>", "<tr>","<td>","<input type ='text' name ='id_num' value ='$Fid_num' >","</td>","</tr>","</br>","</br>";
echo "<tr>","<td>","<label style='color:green'>Address: " ,"</td>","</tr>", "<tr>","<td>", "<input type ='text' name ='address' value ='$Faddress' >","</td>","</tr>","</br>","</br>";
echo "</table>","</br>","</br>";
echo "<input type ='submit' style='color:green;width:120;height:60;border-radius: 25px;' name= 'go' value ='Update'>";
echo "</br>";
echo "</br>";
echo "</br>";
echo "</form>";

最佳答案

有两种可能的解决方案:

  1. 将您的 GET 值插入到 action

     <form action='<your_action>&client_id=<?=$_GET["client_id"]?>'>
  2. GET 值使用隐藏的 input,然后使用 $_POST 而不是 $_GET

     <input type='hidden' name='client_id' value='<?=$_GET["client_id"]?>'>

关于php $_GET 在提交表单后失去值(value),所以我无法使用它更新数据库表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31504543/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com