Re: set password on a page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
20030920160007.11339.qmail@pb1.pair.com">news:20030920160007.11339.qmail@pb1.pair.com...
> How do I set up password on a page so that only restricted people can open
> it?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux