PHP で if/else ステートメントを使用しようとしています。現在私がやろうとしているのは、ユーザーがアクセスしようとしている現在のディレクトリ ( ) 変数
$_SESSION['usr'];
と等しい場合です。$dir_auth2
次に、私が持っているディレクトリまたは index.php にアクセスできます。それ以外の場合$_SESSION['usr'];
は!=
、現在のディレクトリにある場合は、それらをホームページにリダイレクトします。現在、ユーザーが他のユーザーのディレクトリに入力した場合、そこにはアクセスできません。
<?php
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
//This if statement below is the problem
if($_SESSION['usr'] == $dir_auth1) {
//This demo.php is the home page
header("Location: demo.php");
} else {
echo "You are logged in as " . $dir_auth1;
}
$dir = getcwd();
$dir1 = str_replace('/home/pophub/public_html/', '/', $dir);
$dir_auth = getcwd();
$dir_auth1 = str_replace('/home/pophub/public_html/gallry/', '', $dir_auth);
echo $_SESSION['usr'];
echo $dir_auth1;
$dir_user = getcwd();
$dir_user1 = str_replace('/home/pophub/public_html/gallry', '', $dir_user);
?>