d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Changing Content With Php & Html > For Users Logging In
12Next
Add Reply New Topic New Poll
Member
Posts: 37
Joined: Apr 24 2014
Gold: 0.00
Oct 20 2014 12:49pm
All,

I am trying to create a area where my clients can login and access their files & invoices etc. I have created a login script that re-directs to a profile page if successful. What it is, I want all clients to be able to log in and go to a profile.php page and to show up their files. Is there a way of just changing the content for each user that logs in? I can display via session name and that works fine.

All help is appreciated
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 20 2014 05:53pm
can you explain your problem a bit better? you said you want a way to display profile when they log in, but you also already have a script that does it. what do you need that isn't done?
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 20 2014 06:03pm
I'd sooner use a CMS than roll your own session/login code. What's your website?
Member
Posts: 37
Joined: Apr 24 2014
Gold: 0.00
Oct 20 2014 07:59pm
Quote (carteblanche @ Oct 21 2014 12:53am)
can you explain your problem a bit better? you said you want a way to display profile when they log in, but you also already have a script that does it. what do you need that isn't done?


What i need to happen is someone a client to login and the content to change per user but keep it on one page.

www.dawsondesigns.org.uk then login with Midlands Clothing & 123
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 20 2014 08:10pm
Quote (Dawsy @ Oct 20 2014 09:59pm)
What i need to happen is someone a client to login and the content to change per user but keep it on one page.

www.dawsondesigns.org.uk then login with Midlands Clothing & 123


so instead of redirecting, you wanna have just one page for everything? look into SPA

i clicked member's area, but i couldn't click into the username field. it kept popping up a contact page.
Member
Posts: 37
Joined: Apr 24 2014
Gold: 0.00
Oct 20 2014 08:19pm
Quote (carteblanche @ Oct 21 2014 03:10am)
so instead of redirecting, you wanna have just one page for everything? look into SPA

i clicked member's area, but i couldn't click into the username field. it kept popping up a contact page.


That;s weird i've just logged in fine.

Once the client logs in

it gets redirected to profile.php

i want the content inside the profile.php page to change for each client.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 20 2014 08:30pm
Quote (Dawsy @ Oct 20 2014 10:19pm)
That;s weird i've just logged in fine.

Once the client logs in

it gets redirected to profile.php

i want the content inside the profile.php page to change for each client.


how are you displaying your profile.php page? i assume you're first querying the profile data based on userid then displaying that, but it sounds like you're not?
Member
Posts: 37
Joined: Apr 24 2014
Gold: 0.00
Oct 20 2014 08:36pm
Quote (carteblanche @ Oct 21 2014 03:30am)
how are you displaying your profile.php page? i assume you're first querying the profile data based on userid then displaying that, but it sounds like you're not?


Nope not via user id? Via username

Code
<?php
include('db.php');
// We have to start our session every time we're
// going to call our session variable for a
// logged in issue.
session_start();

// Let's also make sure the user is logged in at all
// If the PHP $_SESSION[] array is not (!) set
if(!isset($_SESSION['username']))
{
//Then redirect them to the login page
header( 'Location: login.php' );
}
;
?>
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 20 2014 08:40pm
Quote (Dawsy @ Oct 20 2014 10:36pm)
Nope not via user id? Via username


that only redirects if they haven't logged in. i meant, i assume the "profile" information you want to show is tied to the user, right? so where's your code that shows the profile info? presumably you fetch it from a DB of some sort first.

i'd be careful about using username. using a surrogate key is often a good idea. what if they want to change their username but keep the rest of their data?
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Oct 20 2014 08:41pm
based on their login youll grab their user id, create a session

and with their user id u can fetch all of their info, just make sure the info actually has their user id attached to it in the database

for instance:

user:
id | name | email | phone

invoice
user_id | invoice_num | invoice_path

just a quick example of how many ur db is set up, the invoice_path can go to like a jpg or pdf file inside of a folder.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll