EziBilisim adlı üyeden alıntı: mesajı görüntüle
<?php
error_reporting(0);
//admin
//admin
if (!isset($_SERVER['PHP_AUTH_USER']) or isset($_POST['kaybol'])) {
    header('WWW-Authenticate: Basic realm="Koruma"');
    header('HTTP/1.0 401 Unauthorized');
    echo '<h1>Engellendi!</h1>';
    exit;
} else {
    if(!($_SERVER['PHP_AUTH_USER']=='admin' and sha1($_SERVER['PHP_AUTH_PW'])=='d033e22ae348aeb5660fc2140aec35850c4da997'))
    {
        header('HTTP/1.0 401 Unauthorized');
        exit;
    }
	echo '<h1>Başaırılı!</h1>';
}
?>
<html>
<head>
</head>
<body>
<form method="POST">
<button name="kaybol" type="submit">Kaybol</button>
</form>
</body>
</html>

<?php
error_reporting(0);
if($_GET['gizli'] == "sayfa") {
 
if (!isset($_SERVER['PHP_AUTH_USER']) or isset($_POST['kaybol'])) {
    header('WWW-Authenticate: Basic realm="Koruma"');
    header('HTTP/1.0 401 Unauthorized');
    echo '<h1>Engellendi!</h1>';
    exit;
} else {
    if(!($_SERVER['PHP_AUTH_USER']=='admin' and sha1($_SERVER['PHP_AUTH_PW'])=='d033e22ae348aeb5660fc2140aec35850c4da997'))
    {
        header('HTTP/1.0 401 Unauthorized');
        exit;
    }
	echo '<h1>Başaırılı!</h1>';
	echo '<form method="POST">';
	echo '<button name="kaybol" type="submit">Kaybol</button>';
	echo '</form>';
}
exit;
}
	echo '<h1>Not Found</h1>
	<p>Additionally, a 404 Not Found
	error was encountered while trying to use an ErrorDocument to handle the request.</p>';
?>
Teşekkür ederim hocam. Deneyeceğim bunu.

magicphp adlı üyeden alıntı: mesajı görüntüle
Gerekli olan bilgiler;
sessions(oturumlar) , formlar ve form kontrolü
Bu iki bilgiyi daha iyi öğrenmen gerek.

Session dediğimiz şey basitçe bir bilgisayardan aldığımız bilgileri geçici olarak sunucuda tutan bir sistemdir. Bu sistem neden gerekli ? Kullanıcı bir kez şifreyi doğru girdiğinde bir süreliğine içeriğe erişebilmesi ve her sayfayı yenilediğinde şifreyi yeniden ve yeniden girmesine gerek kalmaması için.

Basit bir kod örneği;(https://stackoverflow.com/a/1381269 bu adresten alındı)
<?php
session_start();

$userinfo = array(
                'user1'=>'password1',
                'user2'=>'password2'
                );

if(isset($_GET['logout'])) {
    $_SESSION['username'] = '';
    header('Location:  ' . $_SERVER['PHP_SELF']);
}

if(isset($_POST['username'])) {
    if($userinfo[$_POST['username']] == $_POST['password']) {
        $_SESSION['username'] = $_POST['username'];
    }else {
        //Invalid Login
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Login</title>
    </head>
    <body>
        <?php if($_SESSION['username']): ?>
            <p>You are logged in as <?=$_SESSION['username']?></p>
            <p><a href="?logout=1">Logout</a></p>
        <?php endif; ?>
        <form name="login" action="" method="post">
            Username:  <input type="text" name="username" value="" /><br />
            Password:  <input type="password" name="password" value="" /><br />
            <input type="submit" name="submit" value="Submit" />
        </form>
    </body>
</html>
Hocam üyelik sistemi istemediğimi belirtmiştim konuda. Bu yüzden session kullanmak istemiyorum. Tek parola olacak ve bunu ayar dosyasından ben belirleyeceğim.