SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

PHP member update profile script using mysql

In membership management script there will be an area where members can add changes to their profile. Here the profile can be updated by the member after they login to the system. Update profile feature can be extended with different features like email is to be validated once it is changed etc. Here we will only see the basic requirement of any update profile script.

The present script will take care of change in name, email address and sex ( for our learning only we have given this option). You can see that for the sex we have used one period button so we will see how by default the selection of period button is done by collecting the old details of the user.

Related Tutorial
PHP Login script
Forgot password script
PHP Change Password
PHP Signup script
The script first collects the details of the user from the table and uses them as default value. The member can check them and add the necessary changes to it. On submit by the member the data will be updated on the table against the user. We have given sufficient comments within the script for easy understanding. You can use the PHP forum to discuss your bugs , improvements and other problems.

Here is the form for update profile
 Update Profile
 Email
 Name
 Sex Male Female


Here is the processing code and you can donwnload the code at the end of this page.

We will start with collecting the form data and checking the session of the user.

$todo=$_POST['todo'];
$name=$_POST['name'];
$email=$_POST['email'];
$sex=$_POST['sex'];
// check the login details of the user and stop execution if not logged in require "check.php";

if(isset($todo) and $todo=="update-profile"){


// set the flags for validation and messages
$status = "OK";
$msg="";


// if name is less than 5 char then status is not ok
if (strlen($name) < 5) {
$msg=$msg."Your name must be more than 5 char length<BR>";
$status= "NOTOK";}

// you can add email validation here if required.
// The code for email validation is available at www.plus2net.com


if($status<>"OK"){ // if validation failed
echo "<font face='Verdana' size='2' color=red>$msg</font>
<br><input type='button' value='Retry' onClick='history.go(-1)'>";

}else{ // if all validations are passed.

if(mysql_query("update plus_signup set email='$email',name='$name',sex='$sex' where userid='$session[userid]'")){
echo "<font face='Verdana' size='2' color=green>You have successfully updated your profile<br></font>";
}else{echo "<font face='Verdana' size='2' color=red>There is some problem in updating your profile. Please contact site
admin<br></font>";}
}}



In the above code the session variable is taken as $session[userid] but in higher version of PHP this has to be taken as $_SESSION[userid]. In the downloaded script ( zip file ) this care is already taken
Download PHP signup with update profile script
Download Modified PHP signup with login script if register_global is off for PHP 5

Discuss this tutorial at forum


Further readings
Online membership management script
Posting Activation key for lost encrypted password to the email address
Creating a signup page and storing member details in MySQL
Storing signup data in a table
Collecting the data if register global is off for signup script
Changing or updating password by the logged in member
Forgot password feature in member signup script
Basic login form
Login script to authenticate user from a mysql table data
Checking the status of user for login or logged out
Updating member profile inside member area
Finding out who are online








 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.