runnerjp Posted May 13, 2007 Share Posted May 13, 2007 hey guys.... wunderd if someone could point me in right direction.... im making a profile site so each person has there on profile page what would be the best way to have the users have there own page if that makes sense? so my profile page would be www.mywebpage.com/admin Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/ Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 I'd use .htaccess mod_rewriting to rewrite /username to /profile.php?user=username for a start. Then I'd put together the profile selecting the info from the database Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252178 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 I'd use .htaccess mod_rewriting to rewrite /username to /profile.php?user=username for a start. this is the part im intrested in...this is new to me...what does it do and how do i do it Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252185 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 in your .htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/\.]+)/?$ profile.php?username=$1 [L] in your profile.php $username = $_GET['username']; //query DB for the username and get the user id this should get you started Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252190 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 .htaccess Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/\.]+) profile.php?user=$1 [nc] profile.php <?php echo $_GET['user']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252192 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 which 1 do i follow lol where do i add the .htaccess file and what is it doing/stopping??? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252201 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 you put your .htaccess file in your web root. You also have profile.php there. The .htaccess is saying take www.mywebpage.com/admin and make it like www.mywebpage.com/profile.php?username=admin get it? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252204 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 yes but wat does changing it do?? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252205 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 not sure I quite understand your question... it allows you to use www.mywebpage.com/admin like www.mywebpage.com/profile.php?username=admin and vice versa Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252214 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 but why would i want to use it as www.mywebpage.com/profile.php?username=admin ???? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252219 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Because then that's where your profile page is generated from. Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252221 Share on other sites More sharing options...
marf Posted May 13, 2007 Share Posted May 13, 2007 Bookmarked myself this useful page. Shows 3 possible solutions http://www.sitepoint.com/article/search-engine-friendly-urls Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252224 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 but why would i want to use it as www.mywebpage.com/profile.php?username=admin ???? you don't need to use it...it's just how it works, the .htaccess converts it to that without you actually seeing it...but thats how the php reads it. Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252229 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 then again tbh what i first need to know his how to create unique pages for the users to use as there profiles lol Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252238 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Why not just use something like this? profile.php <?php $username = $_GET["username"]; $q = mysql_query("SELECT * FROM users WHERE username = '$username'"); $r = mysql_fetch_assoc($q); echo "Welcome to ".$username."'s profile page."; ?> Very basic but it will work Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252242 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 yes but this would not create a new profile page for the user Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252245 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 If you used the .htaccess then somebody can type /username and get taken to the page though. What exactly are you trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252247 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 what about when a users signs up ...is there away that i can take the username and make a page for them with it?? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252254 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 do you mean like making admin.html, user1.html, etc.? Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252257 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 But the solution I've already given you makes it work with new accounts without doing anything. They type "/username" and get taken to their page which is (secretly) found at /profile.php?user=username. It's foolproof and means you don't physically make them a page. Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252261 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 ...correct You don't want to have 50,000 pages if you have 50,000 users if you can just handle 50,000 profiles with 1 file Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252268 Share on other sites More sharing options...
runnerjp Posted May 13, 2007 Author Share Posted May 13, 2007 .htaccess Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/\.]+) profile.php?user=$1 [nc] profile.php <?php echo $_GET['user']; ?> ok so would i put this in a new file called profiles or something to keep it seperate yes Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252269 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Just put it in the root of the folder where your files are stored and test it by typing www.domain.com/username ~ the output should be username Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252271 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 yes, you have 2 files ".htaccess" and "profile.php" Quote Link to comment https://forums.phpfreaks.com/topic/51213-profile-site/#findComment-252273 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.