Log in

View Full Version : Display info of a logged_in user



mtran
04-23-2006, 07:56 AM
Hi,
Again with login page. I have:

1/ login: an html form [with username/password fields]
2/ login_check.php: to validate the username/password against db, if correct then setcookie, and go to 3/ member_only.php.:
How do I make a simple greeting in 3/, say: Welcome <?php print $username; ?>!

All I know so far is in 2/ I can set:
$username=$_POST["username"];
and refer to $username whenever I want to within 2.

But in 3/ I don't know how, because there's no $_POST...

Because I don't know to display that "Welcome...," I don't know how to show/display all info [query from db] related to that user either.
Thanks very much for help!

Twey
04-23-2006, 11:20 AM
Get the info from that cookie you set.
Although I'd advise using sessions, not cookies, here.

mtran
04-23-2006, 06:36 PM
Stumbling and not yet know how to do:

If in 2/ I set:

setcookie('log',$username,time()+3600);

and in 3/ I check cookie:


<?php
require ('config.php');
if(!isset($_COOKIE['log'])){
Header('Location:login.php');}
?>


How do I say welcome [username]? Or Your email is..., your phone is....
Thanks

Twey
04-23-2006, 06:52 PM
Welcome, <?php echo($_COOKIE['log']); ?>!