Jump to content

different page for each user


squiblo

Recommended Posts

hi, my aim is to make a dynamic page for every user, like a profile page, and they can edit the design of the page, such as background color and add text boxes and so on, but firstly how do i create the indiviual page for each user, also what can i search for in google because i do not know where to start with this. thank you

Link to comment
Share on other sites

you need some way of knowing which user's page to display...i would say the most common way is with a GET variable...so the URL would look like:

http://www.yourserver.com/profile.php?user=someusername

 

then, in the profile.php script, you can access someusername via $_GET['user']. from this point, you can branch out in several directions depending on where in the info is for that user (database most likely)

Link to comment
Share on other sites

would something like this work...

 

<?php
session_start();

if($_SESSION['myusername']){

//start example

mysql_connect("***","***","***") or die ("Couldn't connect");
mysql_select_db("***") or die ("Couldn't find db");

$username = isset($_SESSION['myusername'])

mysql_query("SELECT image FROM profile WHERE username='$username'");

?>

 

but the problem i can think of with using this is that, all the pages will have the same layout and i want each user to be able to design thier own layout

Link to comment
Share on other sites

yup, you can read it from the session...but a user will only be able to see their own profile that way. for the ability to see other people's profiles, you will need to use GET

 

so, the template is as dynamic as you want it to be. if you have info for a background color for that user stored in the database, you can select it from the db then do:

<div style="background:<?php echo $color;?>;">

and so on....

Link to comment
Share on other sites

so sessions are used for tracking information while a user is visiting your site...great for logins, etc. but what if you want a URL someone can use to uniquely identify a user's profile? enter GET...it would look like so:

 

<?php
if(!$_GET['user']){
  die("User not found");

mysql_connect("***","***","***") or die ("Couldn't connect");
mysql_select_db("***") or die ("Couldn't find db");

$user = mysql_real_escape_string($_GET['user']);
mysql_query("SELECT image FROM profile WHERE username='$user'");

?>

and the url for this profile would be something like:

http://www.yourserver.com/profile.php?user=someusername

Link to comment
Share on other sites

<?php
if(!$_GET['user']){
  die("User not found");

//would doctype and meta tags go here??

mysql_connect("***","***","***") or die ("Couldn't connect");
mysql_select_db("***") or die ("Couldn't find db");

$user = mysql_real_escape_string($_GET['user']);
mysql_query("SELECT image FROM profile WHERE username='$user'");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.