PHP Classes

File: update_user_profile.php

Recommend this page to a friend!
  Classes of Olaf Lederer  >  Access user Class  >  update_user_profile.php  >  Download  
File: update_user_profile.php
Role: Application script
Content type: text/plain
Description: Update form for user's data and profile
Class: Access user Class
Site user registration and page access restriction
Author: By
Last change: added fields and variables for the new password check
Date: 16 years ago
Size: 3,610 bytes


Class file image Download
error_reporting (E_ALL); // I use this only for testing
$update_profile = new Users_profile;

$update_profile->access_page($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']); // protect this page too.


if (isset(
$_POST['user_data'])) {
$update_profile->update_user($_POST['password'], $_POST['confirm'], $_POST['user_full_name'], $_POST['user_info'], $_POST['user_email']); // the update method
if (isset(
$_POST['profile_data'])) {
$update_profile->save_profile_date($_POST['id'], $_POST['language'], $_POST['address'], $_POST['postcode'], $_POST['city'], $_POST['country'], $_POST['phone'], $_POST['fax'], $_POST['homepage'], $_POST['notes'], $_POST['field_one']);
$error = $update_profile->the_msg; // error message
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Update page example</title>
<style type="text/css">
label {
    display: block;
    float: left;
    width: 120px;

<h2>Update user information:</h2>
<p>This two forms are an example how to update the user and user-profile information <br>
(fields with a * are required).</p>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <label for="login">Login:</label>
  <b><?php echo $update_profile->user; ?></b><br>
  <label for="password">Password:</label>
  <input name="password" type="password" value="<?php echo (isset($_POST['password'])) ? $_POST['password'] : ""; ?>" size="6">
  * (min. 4 chars.) <br>
  <label for="confirm">Confirm password:</label>
  <input name="confirm" type="password" value="<?php echo (isset($_POST['confirm'])) ? $_POST['confirm'] : ""; ?>" size="6">
  * <br>
echo $update_profile->create_form_field("user_full_name", "Real name:", 30);
$update_profile->create_form_field("user_email", "E-mail:", 30, true);
$update_profile->create_form_field("user_info", "Extra info:", 50);
<input type="submit" name="user_data" value="Update (user)">
<h3>User profile</h3>
<p>This form is not saved while saving data for the user account!</p>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
echo $update_profile->create_form_field("address", "Address:");
$update_profile->create_form_field("postcode", "Postcode:", 10);
$update_profile->create_form_field("city", "City:");
$update_profile->create_country_menu("country", "Country:");
$update_profile->create_form_field("phone", "Phone:");
$update_profile->create_form_field("fax", "Fax:");
$update_profile->create_form_field("homepage", "Homepage:");
$update_profile->create_text_area("notes", "Some text...");
// You have to use the same field like the variable in the class
echo $update_profile->create_form_field("field_one", "Userfield 1:");
<input type="hidden" name="id" value="<?php echo $update_profile->profile_id; ?>">
  <input type="submit" name="profile_data" value="Save (profile)">
<p><b><?php echo (isset($error)) ? $error : "&nbsp;"; ?></b></p>
<!-- Notice! you have to change this links here, if the files are not in the same folder -->
<p><a href="<?php echo $update_profile->main_page; ?>">Main</a></p>

For more information send a message to info at phpclasses dot org.