这是我必须使用表单编辑更新来更新数据库中的条目的代码:
<?php
$nm=$_POST['name'];
$ag=$_POST["age"];
$em=$_POST['email'];
$cn=$_POST['contact'];
$ad=$_POST['address'];
require("connection.php");
$sql = "update signup set name='$nm', age='$ag', email='$em', contact='$cn', address='$ad' WHERE id='$id'";
if(mysqli_query($conn,$sql))
{
echo "Updated";
} else
{
echo "Error:";
}
?>
这些是显示的错误.. 我已经尝试过 isset 然后也显示了分配变量的相同错误。
Notice: Undefined index: name in C:\xampp\htdocs\Signup\update.php on line 3
Notice: Undefined index: age in C:\xampp\htdocs\Signup\update.php on line 4
Notice: Undefined index: email in C:\xampp\htdocs\Signup\update.php on line 5
Notice: Undefined index: contact in C:\xampp\htdocs\Signup\update.php on line 6
Notice: Undefined index: address in C:\xampp\htdocs\Signup\update.php on line 7
Notice: Undefined variable: id in C:\xampp\htdocs\Signup\update.php on line 10
Updated
最佳答案
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> <?php
if(isset($_POST['name'])){
$nm=$_POST['name'];
}
if(isset($_POST["age"])){
$ag=$_POST["age"];
}
if(isset($_POST["email"])){
$em=$_POST['email'];
}
if(isset($_POST["contact"])){
$cn=$_POST['contact'];
}
if(isset($_POST["address"])){
$ad=$_POST['address'];
}
require("connection.php");
$sql = "update 'signup' set 'name'='{$nm}', age='$ag', 'email'='{$em}', 'contact'='{$cn}', 'address'='{$ad}' WHERE 'signup'.'id'='{$id}'";
if($conn->query($sql)==="TRUE")
{
echo "Updated";
}
else
{
echo "Error:";
}
?> </code></pre>
</div>
</div>
希望这能回答您的问题。如果是,请评价我的回答
关于mysql - 想要更新数据库中输入的条目。我有代码并显示错误 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51911541/