Click to See Complete Forum and Search --> : forcing a user to enter a password...
neenach2002
08-01-2003, 01:37 PM
ok...I have a NEW forum...other than my OTHEr NEW FORUM...i hve 2 now...
How do I write a cookie saying a user entered the correct password, and then allow them to enter my forum?
I don't want people who don't know the password to be able to see whats in there...so how do I then check the cookie?
I posted this in php, because my forum is php...
Here's a very simpilistic version... http://forums.webdeveloper.com/showthread.php?s=&threadid=9950&highlight=password
neenach2002
08-02-2003, 12:08 AM
oh
so insert
<? include_once("protect.php"); ?>
into the the top of the protected pages?
k, i'll try it
neenach2002
08-02-2003, 12:33 AM
it won't work...
It gives me the following error three times:
Warning: Cannot add header information - headers already sent by (output started at http://cgi-bin.spaceports.com/~psswd/protect.php:1) in /home3/psswd/public_html/phpBB2/includes/page_header.php on line 474
Warning: Cannot add header information - headers already sent by (output started at http://cgi-bin.spaceports.com/~psswd/protect.php:1) in /home3/psswd/public_html/phpBB2/includes/page_header.php on line 476
Warning: Cannot add header information - headers already sent by (output started at http://cgi-bin.spaceports.com/~psswd/protect.php:1) in /home3/psswd/public_html/phpBB2/includes/page_header.php on line 477
and THEN it displays what I want hidden...
Da Warriah
08-02-2003, 08:02 AM
you need to make sure that the cookie is set before ANY output by the code...that includes print, echo, return, etc, which displays anything to the page...
neenach2002
08-02-2003, 02:08 PM
but I'm NOT using a cookie, I'm STILL using that code that pyro posted...THAT doesn't work...I haven't even been able to try a cookie, because the code hasn't been posted yet...
Bootsman123
08-02-2003, 04:09 PM
Post your full code here between [php] tags.
neenach2002
08-02-2003, 04:21 PM
ok...for which?
Bootsman123
08-02-2003, 05:05 PM
The page in which you want to set a cookie or session if doing it with php.
neenach2002
08-02-2003, 05:47 PM
too long...It's an attachment instead...
dunno which one it is that should make the cookie...
:D :D :D
Bootsman123
08-03-2003, 02:11 AM
<?PHP
# Change the below lines to the results that makepass.php gave you
#
$user = 'f1d05700a113ae40dd1d281e82cf371e';
$pass = '130fbd90204fe13e85a35ca2a6d4e386';
#
# Change the above lines to the results that makepass.php gave you
if(md5($_POST['username']) == $user && md5($_POST['password']) == $pass)
{
setcookie ("verified", true);
header ("Location:http://cgi-bin.spaceports.com/~psswd/phpBB2/");
}
else
{
echo ("Incorrect Password");
}
?>
You are setting a cookie. But if that doesn't works, then it could also be that your browser hasn't accepted the cookie or you could try this:
setcookie ("verified", TRUE, time() + 60*60*24*2);
/* experation after 2 days */
neenach2002
08-03-2003, 01:32 PM
cool...now I need the cookie reader...^_^x
Bootsman123
08-03-2003, 02:51 PM
Now I see something really strange:
header ("Location:<a href="http://cgi-bin.spaceports.com/~psswd/phpBB2/" target="_blank">http://cgi-bin.spaceports.com/~psswd/phpBB2/</a>");
I always thought that you couldn't use html in a header, that it had to be something like this:
header ("location: page.html");
And how you read the cookie:
$_COOKIE['verified'] or $verified depending on your settings:
neenach2002
08-03-2003, 03:13 PM
I'm confused....how exactly do I use that code in a page? where does it go?
Originally posted by Bootsman123
I always thought that you couldn't use html in a headerThat is correct. The code above is a simple formatting error by the forums. If the Automatically Parse URLs checkbox was not unchecked, it screws up the code...
neenach2002
08-03-2003, 04:24 PM
???
ok now I'm confused...Now I see something really strange:
header ("Location:<a href="http://cgi-bin.spaceports.com/~psswd/phpBB2/" target="_blank">http://cgi-bin.spaceports.com/~psswd/phpBB2/</a>");
what do you mean?
As I explained above, that is due to a formatting error by the forums. It should be:
header ("Location:http://cgi-bin.spaceports.com/~psswd/phpBB2/");
neenach2002
08-03-2003, 04:55 PM
oh...
i STILL need to know where the code goes...:(