Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How Do I Show Only the Logged In Users Info

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How Do I Show Only the Logged In Users Info

Postby maudenton » Tue Oct 02, 2012 4:09 pm

Hello,
I am a newbie and i created a member site with php and mysql in expression web. I would like each member to be able to view their profile information and be able to update it . For example they click a link that says my profile and their info comes up in a form for them to view and/or edit and update it.
Links to tutorials are always greatly appreciated since i am no good at coding... ;)
Thanks
maudenton
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon Oct 01, 2012 9:32 am

Re: How Do I Show Only the Logged In Users Info

Postby slice » Wed Oct 03, 2012 6:47 am

Well you seem to have your entire site up and running so you must have some coding experience.

What your describing can be done simply by having two seperate files for one page. Let's say you have one php page where all the user info is displayed in the html, uneditable. And the other page, everything is displayed in text boxes with a submit button and an update query to change the information.

Then it would be a simple matter of validating the user
Code: Select all
<?php
if($_SESSION['user'] == $profileUser)
{
    require_once("editable_file.php");
    exit(); // stop the rest of script from executing
}

require_once("non_editable_file.php"); // so if you aren't the user who owns this page, you only see this

?>


Hope that helps :)
slice
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Oct 03, 2012 6:17 am

Re: How Do I Show Only the Logged In Users Info

Postby seandisanti » Wed Oct 03, 2012 8:31 am

personally i'd do it in one page like:

Code: Select all
<?php
if (! isset($_GET['change'])) { //not trying to edit just display
?>
   <!-- html code to display profile -->
   <?php if ($_SESSION['user_id']==$displayed_id) { ?>
      <a href="whatever.php?change=1>Edit your details</a>
<?php } else { //change has been set by user clicking edit link ?>
   <!-- html code to show edit form -->




*** edit ***
fixed typo sorry
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron