Cases using variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
superaimee
Forum Newbie
Posts: 1
Joined: Fri Dec 24, 2004 8:03 pm
Location: Columbia, SC

Cases using variables

Post 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
keiths
Forum Newbie
Posts: 7
Joined: Fri Dec 24, 2004 8:46 pm

Post 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']?>
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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
Post Reply