所以我正在编写代码来更新这些变量的用户个人资料页面。
更新用户名
更新电子邮件
更新密码
由于某种原因,我无法使其正常运行,对此我可以寻求帮助吗?
更新:好的,这样我就可以使用代码了,但是现在还有另一个问题-当尝试使用新的更改信息(即登录名和密码)登录时,我收到一个错误,提示我输入的密码是错误的,我已包含我的Login.inc.php文件供您查看!
Update.php文件
bool[] result = Parent.Controls.OfType<CheckBox>().OrderBy(x => x.Name)
.Select(x => x.Checked).ToArray();
Update.inc.php文件
<?php
require "header.php";
?>
<main>
<div class="wrapper-main">
<section class="section-default">
<h1>Update Profile</h1>
<form class="form-signup" action="includes/update.inc.php" method="post">
<input type="text" name="u-id" placeholder="Username">
<input type="text" name="u-mail" placeholder="E-mail">
<input type="password" name="u-pwd" placeholder="Password">
<button type="submit" name="update-submit">Update</button>
</form>
</section>
</div>
</main>
<?php
require "footer.php";
?>
Login.inc.php文件
<?php
if(isset($_POST['update-submit'])) {
require 'dbh.inc.php';
$u_username = $_POST['u-id'];
$u_email = $_POST['u-mail'];
$u_password = $_POST['u-pwd'];
$update = "UPDATE users SET uidUsers='$u_username', emailUsers='$u_email', pwdUsers='$u_password' WHERE idUsers='$u_username'";
$run = mysqli_query($conn, $update);
if($run) {
echo "<script>Alert('Your profile has been updated!')</script>";
echo "<script>windows.open('index.php','_SELF')</script>";
}
}
?>
谢谢!
答案 0 :(得分:-2)
好吧!所以你的问题就在这里
$update = "UPDATE users SET uidUsers='$u_username', emailUsers='$u_email', pwdUsers='$u_password' WHERE idUsers='$u_username'";
让我们说我的初始数据库是这样的:
idusers uidUsers emailUsers pwdUsers
1 xyz xyz@mail.com 1234
因此,如果我想对上述内容进行任何更改,
$update = "UPDATE users SET uidUsers='abc', emailUsers='abc@gmailcom', pwdUsers='121212' WHERE idUsers='1'";
或以通用方式
$update = "UPDATE users SET uidUsers='$u_username', emailUsers='$u_email', pwdUsers='$u_password' WHERE idUsers='$id'";
您做错了什么
$update = "UPDATE users SET uidUsers='abc', emailUsers='abc@gmail.com', pwdUsers='121212' WHERE idUsers='abc'";
这不起作用,因为您没有idUsers作为abc! 您需要获取current_session idUsers 假设id保存在“ id”中 因此,您对应的SQL查询将是:
$update = "UPDATE users SET uidUsers='$u_username', emailUsers='$u_email', pwdUsers='$u_password' WHERE idUsers='$id'";