Crud 功能,尝试使用 php 和 mysql 更新用户详细信息


Crud functionality, Trying to update user details with php and mysql

我是 php 的新手,我有一个登录系统和一个允许用户编辑他们的详细信息的帐户,但是当他们填写表格时,数据库不会更新,我的错误消息也不会显示?谁能帮忙?

会计修正.php

 <?php
 include 'connection.php'; // this includes my connection to the database
$ID=$_GET['ID'];
$query="SELECT ID, email, password, FROM users WHERE ID=$ID";
$result=mysqli_query($connection,$query) or die (mysqli_error($connection));
if (mysqli_num_rows($result)>0){
$row=mysqli_fetch_assoc($result);
} else {
$row=NULL;
}
?>
<html>
<head>
<title> Update Details </title>
<link rel="stylesheet" href="homecss.css"/>
<link href='http://fonts.googleapis.com/css?family=Nunito:400,700' rel='stylesheet'       type='text/css'>
 </head>
 <body>
<form method ="post" action="amendaccount.php">
    <fieldsetclass="fieldset-width">
 <legend>
Enter New Details
</legend>
<input type="hidden" name"ID" value="<?php echo $ID; ?>" />
<label for="email">Email: </label>
<input type = "text" name="email" value="<?php echo $row['email']; ?>" />
<br/>
<label for ="password"> Password: </label>
<input type = "password" name="password" value="<?php echo $row['password']; ?>" />
</fieldset>
<input type="submit" value="submit" name="submit" />
<input type="reset" value="clear" />
</form>
</body>
</html>

编辑帐户.php

 <?php
include 'connection.php';
$ID=$_POST['ID'];
$email=$_POST['email'];
$password=$_POST['password'];
$query="UPDATE users SET email='$email', password='$password' WHERE ID='$ID'";
mysqli_query($connection,$query);
 echo "Update Success";
 ?>

看起来你的代码中有错误:

<input type="hidden" name"ID" value="<?php echo $ID; ?>" />

应该是:

<input type="hidden" name="ID" value="<?php echo $ID; ?>" />
在您的

编辑帐户中.php您可以添加类似的东西

printf("Errormessage: %s'n", mysqli_error($connection));

mysqli_query,以便您可以看到最新的错误(如果有)。

您是否输出了$query并尝试手动执行?也许这也向您显示错误?