How to configure member's only and sign up?

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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

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... »

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... »

Argh!
Don't click on that link if you are at work!

/edit: As feyd has just pointed out ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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..
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

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

Ok so now Im getting un confused.

Post by girth Brooks »

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? 8O
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

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

Ok thank you

Post by girth Brooks »

so that tag I am going to add to what page? My index page on the chat room?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

uhh, whatever page you wish to make sure the user is logged in.

:?
Post Reply