[SOLVED] Creating an edit profile page.
Posted: Wed Jan 07, 2004 1:56 am
here's my code. i want it to display a form with all the values of each field set to the values alreayd in the database, then have them be able to change it, and have it post to itself and update the database. so far i am only trying it with one variable, first_name, but my code isn't updating the database. it just reloads the page. here's my code:
?>[/quote]
Code: Select all
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix
include 'header.inc';
//update fields posted by form below
if($updated) {
mysql_query("UPDATE users SET first_name=$user[first_name] WHERE username='". $_SESSION['my_username'] ."'");
}
echo "<p align='center'><a href='profile.php?username=". $_SESSION['my_username'] ."'>My Profile</a></p>";
$result = @mysql_query("SELECT * FROM users WHERE username='". $_SESSION['my_username']. "'");
while($user = mysql_fetch_array($result)) {
echo ("
<form action='edit_profile.php' method='post'>
<b>Name:</b> <input type='text' name='first_name' value='$user[first_name]'><br />
<b>Email:</b> <input type='text' name='email_address' value='$user[email_address]'><br />
<input type='hidden' name='updated' value='yes'>
<input type='submit' name='Submit' value='Submit'>
</form>
");
}
echo "<p align=center><a href=logout.php>Logout</a></p>";
include 'footer.inc';
?>