Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.