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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jun 24, 2004 2:10 am
For whatever reason, girth you decided to reply to a thread which had little to do with your issue, so I split the topic.
If anyone cares to know the thread this was split from:
Help Grouping Results of Array
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Thu Jun 24, 2004 2:25 am
well, you might want to have a login screen, and if they can't login they can't get through...
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Thu Jun 24, 2004 4:03 am
Why not use a cookie?
When a user is logged in, use [php_man]setcookie[/php_man]().
Then on the chat page, if the cookie variable doesn't exist, use
Code: Select all
<?php
header("location: login.php");
exit;
?> to send them to the login page.
Grim...
DevNet Resident
Posts: 1445 Joined: Tue May 18, 2004 5:32 am
Location: London, UK
Post
by Grim... » Thu Jun 24, 2004 4:04 am
Argh!
Don't click on that link if you are at work!
/edit: As feyd has just pointed out
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jun 24, 2004 4:06 am
girth, before a LOT of people get in trouble, mark your Sig link NWS.. and might want to think about removing the WWW in your profile.. just to be safe..
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Thu Jun 24, 2004 7:45 am
your better bet would be to use sessions.
As some people disable cookies
girth Brooks
Forum Newbie
Posts: 2 Joined: Thu Jun 24, 2004 12:59 pm
Location: CA
Post
by girth Brooks » Thu Jun 24, 2004 12:59 pm
so now that I've got that code how would I apply it? do I add it to my index page? or do I put it on a seperate page, and then have my index page link or call that page? I am so confused, could you please show me an example, or expalin it as if I were a baby?
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Thu Jun 24, 2004 1:05 pm
Code: Select all
<?php
if (isset($_COOKIE['whatever'])) {
// display page
} else {
// refer to log-in page
}
?>
as said, when the user logs-in, set the cookie, in my above example I called it 'whatever'
for info on setcookie(), check out php.net
girth Brooks
Forum Newbie
Posts: 2 Joined: Thu Jun 24, 2004 12:59 pm
Location: CA
Post
by girth Brooks » Thu Jun 24, 2004 1:26 pm
so that tag I am going to add to what page? My index page on the chat room?
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Thu Jun 24, 2004 1:31 pm
uhh, whatever page you wish to make sure the user is logged in.