我正在尝试创建一个页面,以便用户可以更新其用户名,电子邮件和密码。我已经制作了这个脚本,不确定它是否应该起作用。当我点击更新时,它不会对帐户进行任何更改。不确定它是什么。我把HTML内容留了出来。
<?php
session_start();
require 'core/init.php';
$uname = $_GET['username'];
$username = $_SESSION['username'];
if(isset($_POST['update'])) {
$uname = $_GET['username'];
if(!empty($_POST['username'])) {
$updateuname = $db->prepare("UPDATE users SET username = :username WHERE username='".$uname."'");
$updateuname->bindValue(':username', $_POST['username'], PDO::PARAM_STR);
$updateuname->execute();
if(!empty($_POST['email'])) {
$updateemail = $db->prepare("UPDATE users SET email = :email WHERE username='".$uname."'");
$updateemail->bindValue(':email', $_POST['email'], PDO::PARAM_STR);
$updateemail->execute();
if(!empty($_POST['password'])) {
if(empty($_POST['password_c'])) {
echo 'You must enter your password in both boxes!';
} else {
if($_POST['password'] == $_POST['password_c']) {
$updatepassword = $db->prepare("UPDATE users SET password = :password WHERE username='".$uname."'");
$updatepassword->bindValue(':password', $_POST['password'], PDO::PARAM_STR);
$updatepassword->execute();
} else {
echo 'Passwords did not match';
}
}
}
}
}
echo 'Details updated!';
}
?>