View Full Version : [php & mysql]
chrisclick
April 2nd, 2007, 08:01 AM
I am making a simple php login form which pulls usernames and passwords from a MySQL database.
I need to know how I can set each users homepage.
--------------------------------------------
E.g.
Chris is sent to - chris.php when he logs in
Matt is sent to - matt.php when he logs in
--------------------------------------------
How is this possible?
bwh2
April 2nd, 2007, 08:08 AM
more like welcome.php?user_id=100002
chrisclick
April 2nd, 2007, 08:11 AM
I dont like ?user_id=??????
things
evildrummer
April 2nd, 2007, 08:39 AM
well use mod rewrite and make it /username/home/ which is actually:
home.php?username=username
or have another column in the database which is their homepage.
foodpk
April 2nd, 2007, 09:17 AM
Yeah, use mod rewriting. Place a .htaccess in your root folder, have the .htaccess contain the following:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9\-]+)/?$ /index.php?username=$1 [L,QSA]
Also put in a base tag in your index.php's head like so
<base href="http://www.youriste.com" />
So now if somoeone requests http://www.yoursite.com/matt , he will see that URL but what your server will receive will be a request for index.php?username=matt
I'm sure you know how to handle it from there on.
chrisclick
April 2nd, 2007, 11:28 AM
evildrummer if I put another collumn in the database how will I tell the PHP login thing to go to that directory?
and foodpk, I have no clue what so ever about those index.php?blah=blah things at all. I tried to learn how to but I could not learn.
evildrummer
April 2nd, 2007, 01:06 PM
well if you have the third row, if the user login is correct have the line:
header("location: $home");
where $home is the variable from the third column
foodpk
April 2nd, 2007, 01:11 PM
Hmmm. Ever considered reading some PHP tuts to get the basics first? :)
Anyway, here's a quick crash course. If we visit www.yousite.com/index.php?page=something&user=matt then we can read that data (called GET data) in php this way:
echo $_GET['page'] . " " . $_GET['user'];
That will output: something matt
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.