Re: set password on a page
| From: | Gabriel Peugnet | Date: | Mon, 22 Sep 2003 04:31:56 +0000 |
| Subject: | Re: set password on a page | ||
| References: | 1 | Groups: | php.db php.db php.db php.db php.db php.db |
| Request: | Send a blank email to php-db+get-30605@lists.php.net to get a copy of this message | ||
Use setCookie() function. It places a global variable on the client that
your programs can verify after. See the manual for the use of the function.
Here is an example:
// Example of file chkacces.php.
<?php
$pass = $_POST['password']; // It receives the password from a <FORM>
with POST method.
if( ($pass != "xyz" ){ // where "xyz" is the right password.
echo "You are not autorized to see this page";
return;
}
// Autorized.
setCookie( $USER, "autorized" );
header( "Location: index.php" ); // redirects to index.php
?>
Example for your index.php file:
<?php
if( ($USER != "autorized" ){
echo "You are not autorized to see this page";
return;
}
// Here goes the code for autorized users.
?>
The variable set with setCookie() is not availabe until the script ends. See
details in the manual.
The manual is available in www.php.org
"Sagerat" <wmingkid@indosat.net.id> escribió en el mensaje
news:20030920160007.11339.qmail@pb1.pair.com...
> How do I set up password on a page so that only restricted people can open
> it?