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.

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.

require "check.php";

$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

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.
//////////////////////////////////////////////////////////
$sql=$dbo->prepare("update plus_signup set name=:name,email=:email,sex=:sex where userid='$_SESSION[userid]'");
$sql->bindParam(':name',$name,PDO::PARAM_STR, 25);
$sql->bindParam(':email',$email,PDO::PARAM_STR, 15);
$sql->bindParam(':sex',$sex,PDO::PARAM_STR, 7);
if($sql->execute()){
echo "<font face='Verdana' size='2' color=green>You have successfully updated your profile<br></font>";
}// End of if profile is ok
else{
print_r($sql->errorInfo()); // if any error is there it will be posted
$msg=" <font face='Verdana' size='2' color=red>There is some problem in updating your profile. Please contact site admin<br></font>";
}// end of if else if database updation failed
}// end of if else for satus<> ok
echo $msg;
}// end of todo to check form inputs


Google+
vicky24-10-2013
it's nice and great and exactly what i am looking for,

i am suggesting about including profile picture for user if you could do that it would be great to see.
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer