I'm seriously confused.. I'm making a login, and I added an option so that I could edit users, It comes up with a list of the users in the database, I click one, it brings up the information into a form, and then I edit it.. Everything seems to work fine, there is no errors, nothing at all, when I made it display the SQL it came out with "1", so it should be working? But it doesn't edit the user.. I don't understand why..
Links to Users Function:
function editLinks() {
echo '<center><font color="blue"><b>Select a user:</b></font><br /><br />';
$query = sprintf("SELECT username, password FROM users");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<a href="main.php?user='.$row['password'].'">'.$row['username'].'</a><br />';
}
mysql_free_result($result);
}
Form Function:
function editForm($password) {
$query = sprintf("SELECT username, password, email, rank FROM users WHERE password = '$password'");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<center><font color="blue"><b>Edit User:</b></font><br /><br />'
. '<form action="main.php" method="POST">'
. '<b>Username:</b><br />'
. '<input type="text" name="username" value="'.$row['username'].'" /><br /><br />'
. '<b>Change Password:</b><br />'
. '<input type="password" name="password" /><br /><br />'
. '<b>Email:</b><br />'
. '<input type="text" name="email" value="'.$row['email'].'" /><br /><br />'
. '<b>Rank:</b><br />'
. '<input type="text" name="rank" value="'.$row['rank'].'" />'
. '<input type="hidden" name="initialPassword" value="'.$password.'" /><br />'
. '<input type="submit" name="editSubmit" value="Edit User" />'
. '</form></center>';
}
mysql_free_result($result);
}
Process Function:
function editProcess($username, $password, $rank, $email, $intipassword) {
mysql_query("UPDATE users SET username = '$username', password = '$password', rank = '$rank', email = '$email' WHERE password = '".$intipassword."'");;
if (mysql_error() !== "") {
echo '<center><b>Error:</b> <i>'.mysql_error().'</i></center>';
} else if (!mysql_error()) {
echo '<center><b>Success:</b> User was edited successfuly.</center>';
}
}
Call to Links Function:
else if ($_GET['panel_op'] == "edit") {
$panel->editLinks();
}
Call to Form Function:
else if (isset($_GET['user'])) {
$panel->editForm($_GET['user']);
}
Call to Process Function:
else if (isset($_POST['editSubmit'])) {
$panel->editProcess($_POST['username'], md5($_POST['password']), $_POST['rank'], $_POST['email'], $_POST['intialpassword']);
}
If you need me to give you the full files of each things just tell me. Thanks!