0

ウェブページのアイデアの一部をテストしながら、少しずつウェブページを作成しています。ページをセッション保護する方法を知りたいです。ページを安全にパスワードで保護しましたが、URL を入力するだけで誰でもページにアクセスできます。誰もそれをできないように、自分のページをセッション保護したい。私は3つのページを持っています:password.phpを送信するフォームを持つindex.html、「ifステートメント」を使用してパスワードとユーザー名が正しいことを確認するpassword.php(ここでは「ifステートメント」)

    if ($username == 'mgmb99'){
    if ($password == 'mgmb91mas'){
    header('Location: youhere.php');
    } else {
    echo 'your username or password is wrong.<a href="http://www.passwordtest.comze.com"> go back to login page </a>';
    }} else {
    echo 'your username or password is wrong.<a href="http://www.passwordtest.comze.com"> go back to login page </a>';
    };

、およびログイン後のページである youhere.php です。

4

2 に答える 2

0
do like this
<?php
session_start();
if ($username == `enter code here`)
{
    if ($password == `mgmb91mas`)
    {
      $_SESSION[`id`]='Secret code';
      header(`Location:page.php`);
    }
?>
and check that id in the next page at start like below
<?php
session_start();
if($_SESSION['id']!='Secret code')
{
header('Location:inde.php');
}
?>
于 2013-03-31T17:19:56.843 に答える