473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to provide user Edit Profile option?

I am creating a database-driven Web page to display member information for an organization to which I belong. I want to allow members to edit/modify most of the information for their individual profiles.

I have the basic MySQL database and PHP Members page created and working the way I want. What I want to do is add an option for each member to edit his/her own profile. I am not sure the best way to go about this with PHP, but I have considered a couple different options:
  • (Preferred) Add a link that appears only on the entry for the member viewing the page. I assume this would require a cookie to identify the person viewing? But on what basis? What would be the best mechanism to use for the "Edit Profile" link to appear only on that member's entry? Is it even possible?
  • (Probably more practical) Have the "Edit Profile" link appear on each member's entry, and use a password option so that only the member who "owns" that entry can actually change it. This, I think, would be less attractive, but easier and more doable, yes?
Are there other options or possibilities that I have not considered?

I should probably add that I am really new to all this MySQL and PHP stuff, and although I have already learned a lot, I know I have a WHOLE LOT MORE to learn! I am still very much a newbie!

Any tips or guidance will be GREATLY appreciated!

Thanks!
Chuck
Nov 27 '10 #1
1 25861
How do you authenticate users? Some will disagree with me on this, but I use the $_SESSION array to store user info.

Basically, the login script sets $_SESSION variables, such as username, email, or other frequently-accessed information.
Let's say for this example, we stored $_SESSION['USERID'], which is a unique ID in the database, and $_SESSION['USERNAME'], which should be unique as well.

Create "edit-profile.php", and create a blank form with the fields you would like to edit (name, address, email, etc). I'll just use "email" as an example here.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $sql = mysql_query("SELECT * FROM users WHERE userid='$_SESSION['USERID']' LIMIT 1");
  4. while($row = mysql_fetch_assoc($sql)){
  5.     $email = $row[email];
  6.     //--repeat for each field you want to edit
  7. }
  8. ?>
  9.  
  10. <html>
  11. <form name="editprofile" action="process.php" method="post">
  12.  
  13. E-Mail Address: <input type="text" name="email" value="<?=$email; ?>" />
  14.  
  15. //-repeat for each field
  16. </form>
  17.  
  18.  
All this does is create a form, inputs the existing values (from the database) into the form. Process.php will handle putting the new data back into the database. This form will work for all users, as it will only put info from the database WHERE userid= the stored ($_SESSION) user ID.
Nov 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: givlerj | last post by:
I need some help. Here is a little background, I support a MS Access 2k DB (SQL Server 2k backend) that has courses and students. The problem form lets the user pick a course from a drop down and...
1
by: ad | last post by:
I use DataGrid in my web application for editing data. But the DataGrid can edit one row at a time. How can I let the user edit multiple rows at a time?
1
by: Bhaskar | last post by:
I have a serious problem in .NET currently. I am hoping somebody out there can help me. I have a ASP.NET application written in VB.NET and requires the user to log in. I authenticate user using...
0
by: Matteo Basei | last post by:
How can I edit the windows registry obtained from PROFILEINFO.hprofile pointer? I have obtained the struct PROFILEINFO with LoadUserProfile(token,PROFILEINFO).
4
by: Karthik Gurusamy | last post by:
Hi, I see that I can provide a default value for an option. But I couldn't find out any way if the user really entered the option or the option took that value because of default. A simple check...
3
by: anacool | last post by:
HI! Everybody.. I have made my webpage using Html and php code but now i want to add a page in which viewers can register and view their profile. i would appreciate,if any one could guide me to...
3
by: lkjhgfdsa | last post by:
Hi I create a user account in active directory and set the profile value (fill the "homedirectory" and "homedrive" properties and update user account). When I do this steps in "Active Directory...
1
by: shapper | last post by:
Hello, How can I edit the profile of a non authenticated user? I want to edit profiles, as administrator, of users. Thanks, Miguel
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.