mysql - Different page for different users using PHP -


i want know how user 'mckenzie' see own unique page can manipulate , 'wendy' see own page when logs in.

i've created login , pages, connected them mysql database given them id's etc, can of , know sessions etc. ;)

so can tell me how this, have make different pages each separate user? i'm thinking along lines of

register page:

store data in database, user id , use "?pageid=1" take user id based page.

but i'm not sure how make each page without making them manually, can imagine making new page each separate user pain... , inefficient. ideas?

and please show me example code, appreciated! thank in advance!

my answer assuming want create customizable user data added possibility of sharing page between users (like profile page). out of way can creating 1 php page searches mysql table $_get or $_post data.

ill expand answer in couple of steps...

sql tables

the first thing need mysql set-up, ill assume have basic set-up done go ahead , create simple one.

the basic set-up login data , custom user data, can view set-up here.

php user page

the simplest way requested user $_get data. data , request users information:

$requested_user = $_get['id'];  $db = new pdo('mysql:host=localhost;dbname=testdb;charset=utf8', 'root', 'mypassword');  try {      $stmt = $db->prepare("select * c_userpage id = ?");      $stmt->execute(array($requested_user));      $mydata = $stmt->fetch();  } catch (exception $e) {      //error mysql     die();  } 

now can add users data page!

echo "hello! name {$mydata['username']}!\n"; echo "about me: {$mydata['custom_data']}"; 

sending users page

we can use www.page.com/user.php?id=2 , request data user id=2

extras

if want keep user pages private can request id $_post or $_session , check if user logged in!

full code user.php

full code user.php w/ private page


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -