Jump to content

MySql, dorpdown update?


Drewdle

Recommended Posts

I have an edit profile page:

<?php
include ('header.php');
?>
</center>
<div class="content">
<?php
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) {
    $nameuser = $_GET['username'];
    $checkinfo = mysql_query("SELECT * FROM users WHERE Username = '$nameuser'");
    while($results = mysql_fetch_array($checkinfo,MYSQL_ASSOC)) {
        $id = $results['UserID'];
        $username = $results['Username'];
        $email = $results['EmailAddress'];
        $location = $results['Location'];
        $website = $results['Website'];
        $about = $results['About'];
        $level = $results['Level'];
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $editEMAIL=$_POST['email'];
        $editLOCATION=$_POST['location'];
        $editWEBSITE=$_POST['website'];
        $editABOUT=$_POST['about'];
        $editID=$_POST['id'];
        $editLEVEL=$_POST['level'];
        $editquery = mysql_query("UPDATE users SET EmailAddress='$editEMAIL' , Level='$editLEVEL' , Location='$editLOCATION', Website='$editWEBSITE', About='$editABOUT' WHERE UserID='$editID'");
        if($editquery) {
            echo "<b>Success!</b><br>";
            echo "Your profile was successfully updated. Please click<span class=\"class1\"><a href=\"index.php\"> here </a></span>to return to the index.<br><br>";
            $display_form = FALSE;
        } else {
            echo "<b>Error</b>";
            echo "<p>Sorry, your profile update failed. Please go back and try again.</p>";
            $display_form = TRUE;
        }
    }
}
if ($display_form === TRUE || $_SERVER['REQUEST_METHOD'] != 'POST') {
?>

<b>Editing <? echo $username ?>'s Profile</b><br><br>
<b>Current user level:</b> <? echo $level ?>
<br><br>
Please enter your details below to update your profile.
<br><br>
<form method="post" action="editprofile.php" name="editform" id="editform">
<table width="700px" border="0" cellspacing="10"><tr><td valign="top"><table border="0">
<b>Required Information:</b><br><br>
<tr><td>
<b>Username:</b>
</td><td>
<?php echo $username; ?>
</td></tr><tr><td>
<b>Email Address:</b>
</td><td>
<input type="text" name="email" id="email" value="<?php echo $email; ?>">
<input type="hidden" name="id" value="<?php echo $id; ?>">
</td></tr>
<tr><td>
<b>Change Users Level:</b>
</td><td>
<select name="level" id="level">
<option value="Registered User">Registered User</option>
<option value="Eventsec Employee">EventSec Emplyee</option>
<option value="Admin">Admin</option>
</select>
</td></tr>
</table></td><td valign="top">
<table border="0">
<b>Optional Information:</b><br><br>
<tr><td>
<b>Location:</b>
</td><td>
<input type="text" name="location" id="location" value="<?php echo $location; ?>">
</td></tr><tr><td>
<b>Your Website:</b>
</td><td>
<input type="text" name="website" id="website" value="<?php echo $website; ?>">
</tr></td><tr><td valign=top>
<b>Short About:</b>
</td><td>
<textarea name="about" id="about" rows="10" cols="20" ><?php echo $about; ?></textarea>
</td></tr></td>
</table> </td></tr> </table>
<input type="submit" name="register" id="register" value="Update" class="btn">
</form>
</div>

<?php
}
include ('footer.php');
?>

 

However the dropdown menu in the form doesn't work? It returns an update success message but the value of 'level' was not changed in the database.

 

Am I missing something?

 

Link to comment
https://forums.phpfreaks.com/topic/224755-mysql-dorpdown-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.