我是php的新手,我有一个登录系统和一个帐户,允许用户编辑他们的详细信息但是当他们填写表格时数据库没有更新,我的错误信息没有显示?有人可以帮忙吗?
accountamend.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>
editaccount.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";
?>
答案 0 :(得分:1)
您的代码中似乎有错误:
<input type="hidden" name"ID" value="<?php echo $ID; ?>" />
应该是:
<input type="hidden" name="ID" value="<?php echo $ID; ?>" />
答案 1 :(得分:0)
printf("Errormessage: %s\n", mysqli_error($connection));
在你的mysqli_query语句之后,这样你就可以看到最新的错误(如果有的话)。
您输出了$ query并尝试手动执行吗?也许这会显示错误?