我有一个管理员页面,允许管理员编辑刚刚注册的用户的详细信息。每个人的“访问级别”默认为4,由管理员将其访问级别更改为“2”(对于导师)或“3”(对于学生)。
adminpage.php
T.get('followers/ids', { screen_name: 'kanyewest' }, function (err, data) {
console.log(data.ids)
});
editUser.php
<div class="container">
<h3> New Members </h3>
<?php
$query = "Select * FROM users WHERE accessLevel = '4'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$userID = $row['userID'];
$firstName = $row['firstName'];
$lastName = $row['lastName'];
$emailAddress = $row['emailAddress'];
$accessLevel = $row['accessLevel'];
echo
"<div class = 'row'>
<div class='col-sm-12 col-md-6 col-lg-3'>
<div class='box'>
<h5> User ID: $userID </h5>
<h5> User Name: $firstName $lastName </h5>
<p> Email: $emailAddress </p>
<p> Access Level: $accessLevel</p>
<a href = 'editUser.php?getUser=$userID' name='Edit Details' class = 'button'>Edit Details</a>
</div>
</div>
</div>";
}
}
最后,updatedProfile.php
<?php
include ('connection.php');
$getID = $_GET['getUser'];
$query = "Select * From users where userID ='$getID'";
$return = mysqli_query($conn, $query);
?>
<?php
include ('connection.php');
$userQuery = "Select * FROM users WHERE userID = '$getID'";
$return = (mysqli_query($conn, $userQuery));
if (mysqli_num_rows($return) > 0) {
while ($row = mysqli_fetch_assoc($return)) {
$userID = $row['userID'];
$firstName = $row['firstName'];
$lastName = $row['lastName'];
$emailAddress = $row['emailAddress'];
$password = $row['password'];
$accessLevel = $row['accessLevel'];
}
echo
"<h5> Edit Profile for $firstName $lastName </h5>;
<form class ='form' method ='POST' name ='Update' action= 'updatedProfile.php?getid=$getID'>
<fieldset>
<legend>Update Profile Details</legend>
<div class = 'input-group fluid'>
<label for = 'userID'>UserID</label>
<input type = 'number' value='$userID' id ='userID' placeholder = 'UserID'>
</div>
<div class = 'input-group fluid'>
<label for = 'firstName'>First Name</label>
<input type = 'text' value='$firstName' id = 'firstName' placeholder = 'FirstName'>
</div>
<div class = 'input-group fluid'>
<label for = 'lastName'>Last Name</label>
<input type = 'text' value = '$lastName' id='lastName' placeholder = 'Last Name'>
</div>
<div class = 'input-group fluid'>
<label for = 'emailAddress'>Email</label>
<input type = 'email' value='$emailAddress' id ='emailAddress' placeholder = 'emailAddress'>
</div>
<div class = 'input-group fluid'>
<label for = 'emailAddress'>Password</label>
<input type = 'password' value='$password' id ='password' placeholder = 'Password'>
</div>
<div class = 'input-group fluid'>
<label for = 'emailAddress'>Access Level</label>
<input type = 'number' value='$accessLevel' id ='accessLevel' placeholder = 'Access Level'>
</div>
<button>Update Details</button>
</fieldset>
</form>
</div>
</div>
</div>
</div>";
}
?>
<?php
include("connection.php");
if (isset($_POST['userID'])) {
$userID = $_POST['userID'];
} else {
$error = true;
echo "big error";
}
if (isset($_POST['emailAddress'])) {
$emailAddress = $_POST['emailAddress'];
} else {
$error = true;
}
if (isset($_POST['firstName'])) {
$firstName = $_POST['firstName'];
} else {
$error = true;
}
if (isset($_POST['lastName'])) {
$lastName = $_POST['lastName'];
} else {
$error = true;
}
if (isset($_POST['accessLevel'])) {
$accessLevel = $_POST['accessLevel'];
} else {
$error = true;
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
} else {
$error = true;
}
if (!$error) {
//$update = "UPDATE `rdonaghy08`.`users` SET userID='$userID', `firstName` = '$firstName', `lastName` = '$lastName', `password` = '$password', `accessLevel` = '$accessLevel' WHERE `users`.`userID` = '$getID'";
$update = "UPDATE users SET userID='$userID', firstName = '$firstName', lastName = '$lastName', password = '$password', accessLevel = '$accessLevel' WHERE userID = '$getID'";
$return = mysqli_query($conn, $update) or die(mysqli_errno($conn));
}
我知道要查看的代码很多,我真的不认为有人为我这样做,我只是想知道我是否遗漏了一些简单的东西,或者我是否可以指向正确的方向。电子邮件发送正常,只是数据库永远不会更新,具体而言,访问级别永远不会更新,比如从默认的4到3。
任何人都可以提供帮助吗?非常感谢!