Well I cant quite show ALL my code but here is a fair chunk of it.
Code:
//if submitted
if (isset($_POST['submitted'])) {require_once (MYSQL); // From another file to connect to database
$professional = $_POST["professional"];
// Make the update query.
$q = "UPDATE users SET professional='$professional' WHERE user_id={$_SESSION['user_id']}";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));}
//filling in the form
require_once(MYSQL); // From another file to connect to database
$q = "SELECT professional FROM users WHERE user_id={$_SESSION['user_id']}";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
$_display = mysqli_fetch_array ($r, MYSQLI_ASSOC);
?>
<form action="my_file.php" method="post">
<p><b>Professional Page:</b><textarea name="professional" COLS=40 ROWS=8><?php echo $_display['professional']; ?></textarea></p>
<div align="center"><input type="submit" name="submit" value="Edit my profile" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
This updates fields in the database (for profiles in my case) and then displays them for the user in the same input box. This allows the user to dynamically edit their profile with ease. Once you have a login system it should be easy to implement this code.
Bookmarks