without using URL rewriting. The $_SERVER[“PATH_INFO”] contains the stuff that comes after “user.php” (your script), in this case it contains “/some_identifier” and you can parse that and do what you want with it, just like you would with a $_GET variable.
Now, in some really fancy apps, you might have
somesite/controller.php/user/{user_id}
in this case, “controller.php” is a “superscript” that renders all (or many) of the pages on your site, and it’s smart enough to see that the PATH_INFO starts with /user/, and pass the job to some component that reads the {user_id} and then draws the right page. There all kinds of architectural advantages of this, and its the way that modern ‘MVC’ webapps work.
Now, if you don’t like the “.php” there are a bunch of ways to make that go away.
$_SESSION variables create nightmares for people who don't [I]really[/I] understand what they do. You'd do much better as a PHP beginner if you pretended that they don't exist, [B]trust me[/B].
In your case, just use good 'old $_GET instead of $_SESSION. $_GET captures any variables that are defined in the URL and does the job nice and easy.
So it is like second choice only instead if id you use username as the identifier. You then select your data from database using WHERE username='$_GET[‘username’]
username is usually just as unique as the id, so it will work.
Then you can make the first choice http://domainname.com/USERNAME and then
just use rewrite rule to redirect to the third choice
So the url bit is optional, what do you want help with here? If you have absolutely no idea what to do then google for some basic turorials. Otherwise, have a go, and come back here with some code when you get stuck.
which works great for someone who is logged in, but 1) I think it’s just the incorrect way to go about it and 2) it is completely useless for someone who ISN’T logged in trying to view someones user page.