Click to See Complete Forum and Search --> : Secure Page


soccer362001
09-16-2003, 03:36 PM
I've already got a login script. Now all I need is a script that will not allow someone to access the page without logging in. Can someone help me?

pyro
09-16-2003, 05:07 PM
When they log in, set either a cookie, or start a session, and if the cookie/session do not exist, you know that they are not logged in.

soccer362001
09-16-2003, 05:08 PM
1. I don't know how to set a cookie.
2. I want something that says you are not logged in.

pyro
09-16-2003, 05:12 PM
1: http://us3.php.net/manual/en/function.setcookie.php

2: if (!isset($_COOKIE['cookiename'])) {
echo "You are not logged in.";
exit();
}

soccer362001
09-16-2003, 05:40 PM
I cant seem to get this to work.

if (!isset($_COOKIE['cookiename'])) {
echo "You are not logged in.";
exit();
}

I keep getting

parse error in /home/cvedge/public_html/members.php on line 1

pyro
09-16-2003, 10:57 PM
Post your entire code, please...

soccer362001
09-17-2003, 10:06 AM
Hope this helps.

<?php if (!isset($_COOKIE['cookiename'])) {
echo "You are not logged in.";
exit();
}
?>
<font face="Descent ][ Logo" size="6" color="#00ff00"><b>Welcome to the Members area. This portion is still under construction.</b></font>

pyro
09-17-2003, 01:58 PM
Hmm... the code looks good, unless my eyes are just missing the obvious. Did you swap out cookiename for the name of the cookie?

soccer362001
09-17-2003, 01:59 PM
No I did not swap the names.

And just so you know I know nothing about sever side languages.

pyro
09-17-2003, 02:02 PM
Wait a second. What version of PHP are you using? If you are using PHP < 4.2.0, the superglobals variables do not exist, and you'll have to use $HTTP_COOKIE_VARS, like this:

<?php if (!isset($HTTP_COOKIE_VARS['cookiename'])) {
echo "You are not logged in.";
exit();
}
?>Also, don't forget to change cookiename to the name of your cookie.

soccer362001
09-17-2003, 02:07 PM
Do I have to create a cookie? If so how?
And I have no idea what version of php I am using.

I really appreciate you trying to help me and I'm sorry I know nothing about PHP.

pyro
09-17-2003, 05:21 PM
To find out what version of PHP you have, run this:

<?PHP
phpinfo();
?>

setcookie ("cookiename", true);There are quite a few additional paramaters that may be useful to you, so look at http://us3.php.net/manual/en/function.setcookie.php

soccer362001
09-17-2003, 05:27 PM
My php version is 4.3.2 if that helps

pyro
09-17-2003, 05:38 PM
The original code should not have produced an error then. It didn't on my testing server, which is running PHP 4.3.1

soccer362001
09-17-2003, 05:41 PM
This is what I have.

<?php
setcookie ("members", true);
?>
<?php if (!isset($HTTP_COOKIE_VARS['members'])) {
echo "You are not logged in.";
exit();
}
?>


<font face="Descent ][ Logo" size="6" color="#00ff00"><b>Welcome to the Members area. This portion is still under construction.</b></font>


and the link to the page is http://www.cuttingedge.compactvision.net/members.php

pyro
09-17-2003, 09:06 PM
Honestly, I don't know what to tell you. The code works fine for me...

soccer362001
09-17-2003, 09:26 PM
Thanks for your help I'll see if my friend can come up with anything. :(

pyro
09-17-2003, 09:41 PM
No problem. Wish I knew what was going on... :(

soccer362001
09-18-2003, 02:07 PM
Don't worry anymore my friend, known as JONA, fixed it for me. And it works great!!!:D :D :D :D

Jona
09-18-2003, 02:09 PM
Originally posted by soccer362001
Thanks for your help I'll see if my friend can come up with anything. :(

You make it sound as if I'm not capable. :rolleyes:

[J]ona

soccer362001
09-18-2003, 02:11 PM
Thats not at all what I meant Jona;)

Jona
09-18-2003, 02:28 PM
I know. ;)

:D

[J]ona

pyro
09-18-2003, 06:38 PM
Anyone care to let the rest of us in on what the problem was?

chris9902
09-18-2003, 06:43 PM
lol

PS. Pyro read your PM's

Jona
09-18-2003, 06:45 PM
Originally posted by pyro
Anyone care to let the rest of us in on what the problem was?

Actually, I don't even know what it was... lol. I just started all over again, and it worked fine. I guess he screwed it up somewhere along the line. (Great work, man. ;) lol, I'm just messin' with ya. Hehe...)

[J]ona

pyro
09-18-2003, 06:52 PM
Guess I was just curious, as I know the code I posted was correct. Had to be something between the forums, and his server...

Also, chris9902, I just got home, but I have answered your PM.

soccer362001
09-18-2003, 09:30 PM
The odds are I probably screwed up but I don't know enough to fix whatever I messed up.