squiblo Posted August 28, 2009 Share Posted August 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/ Share on other sites More sharing options...
rhodesa Posted August 28, 2009 Share Posted August 28, 2009 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) Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908541 Share on other sites More sharing options...
squiblo Posted August 28, 2009 Author Share Posted August 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908548 Share on other sites More sharing options...
rhodesa Posted August 28, 2009 Share Posted August 28, 2009 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.... Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908557 Share on other sites More sharing options...
squiblo Posted August 28, 2009 Author Share Posted August 28, 2009 what would an example of $_GET look like? does the $_GET replace the session or to get items info from the database? Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908574 Share on other sites More sharing options...
rhodesa Posted August 28, 2009 Share Posted August 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908580 Share on other sites More sharing options...
squiblo Posted August 28, 2009 Author Share Posted August 28, 2009 <?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'"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/172314-different-page-for-each-user/#findComment-908609 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.