Page 1 of 1

Cases using variables

Posted: Fri Dec 24, 2004 8:09 pm
by superaimee
Silly question, but is it possible to make a variable a case?

I've seen sites do this where the URL is
http://www.siteurl.com/viewprofile.php? ... ergoeshere]

and displays their profile accordingly.

How is this done?

Another thing, is it possible to just assign a new session variable that stores the requested profile's user ID within an existing session to do this? And then have it access the database and retrieve the profile?

Any ideas? I'm designing a members-only profile site and want to design it in the most efficient way possible.

Thanks in advance for any comments,

Aimee

Posted: Fri Dec 24, 2004 8:50 pm
by keiths
Usually the way you would do this is:

Code: Select all

<?php
$sql = "SELECT username, email_address FROM users where id = ". $_GET['uid'];
$result = mysql_query($sql);
$r = mysql_fetch_array($result);
?>
Then you can echo your fields and place them where you want on the page by using <?=$r['username']?>

Posted: Fri Dec 24, 2004 11:37 pm
by scorphus
This post may be of a little help. Also take a look at Martin Jansen's PEAR Package Auth, which is an authentication system that might fit your needs.

-- Scorphus