<?
session_start(); //allows session
include "config.php"; // Includes the config
if($logged[username] && $logged[level] == 6)// Checks you are an admin
{
if($_GET[member])//gets the username
{
if (!$_POST[edit])//Checks if you are editing a user already
{
$user = mysql_query("SELECT * from members where username = '$_GET[member]'");// Selcts the right user from the database
$users = mysql_fetch_array($user);
echo "<form method='POST">
<table width="100%">
<tr>
<td align="right" width="25%">
User Level</td>
<td align="left">
<select name="level">
<option value="2">User</option>
<option value="4"> Mod </option>
<option value="6"> Admin</option>
</select> </td>
</tr>
<tr>
<td align="right" width="25%">
Email</td>
<td align="left">
<input type="text" size="25" maxlength="25" name="email"
value="$users[email]"></td>
</tr>
<tr>
<td align="right" width="25%">Location</td>
<td align="left">
<input size="25" name="location" value="$users[location]"></td>
</tr>
<tr>
<td align="right" width="25%">Age</td>
<td align="left">
<input size="25" name="age" value="$users[age]"></td>
</tr>
<tr>
<td align="center"></td>
<td align="left">
<input type="submit" name="edit" value="Update"></td>
</tr>
</table>
</form>
"; // Displays the form
}else{
$email = htmlspecialchars($_POST[email]);//removes all HTML
$age = htmlspecialchars($_POST[age]);//removes all HTML
$location = htmlspecialchars($_POST[location]);//removes all HTML
$level = htmlspecialchars($_POST[level]);//removes all HTML
echo "Thank you $logged[username], $_GET[member]'s Profile was updated!"; // Shows the message of your choice (feel free to change it)
$update = mysql_query("Update members set location = '$location', age = '$age', level = '$level', email = '$email' where username = '$_GET[member]'"); // updates the user
}
}else{
$adminuser = mysql_query("Select * from members order by username asc"); //Makes a list of all the users in alphabeticle order!
while($adminusers = mysql_fetch_array($adminuser))
{
echo "<a href='admin.php?member=$adminusers[username]'>$users[username]</a>"; //Displayes the links to edit the user.
}
}
}else{
//If someone is trying to get onto this page without being an admin then they wont get through!
echo "Sorry, but only Admins may view this page. Please go back!";
}
?>
This might work, the form part was messed. Just copy and paste it.
If you want to know what I did:
In the echo part I changed the " to '. If you did echo "<form action="blahblah"... then the second " would end the echo and possibly cause a error.
This should work if you use my code.