Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Password

Simple script for the protection of a page.



<?php
if(!isset($PHP_AUTH_USER))
{
    Header("WWW-Authenticate: Basic realm=\"Xavier Protection\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "Text to send if user hits Cancel button\n";
    exit;
}
else
{
    $user_passwords = array (
    "user1" => "password1",
    "user2" => "password2",
    "user3" => "password3",
    "user4" => "password4"
    );
    if (($PHP_AUTH_USER == "") || ($PHP_AUTH_PW == ""))
    {
        Header("HTTP/1.0 401 Unauthorized");
        echo "Sorry, could find your password!";
        exit;
    }
    else if (strcmp($user_passwords[$PHP_AUTH_USER],$PHP_AUTH_PW) == 0)
    {
        echo "This is the password protected page.";
        exit;
    }
    else
    {
        Header("HTTP/1.0 401 Unauthorized");
        echo "Sorry, could find your password!";
        exit;
    }
}
?>


Download code...


Print this page


 

Inizio pagina

risorse per webmaster