<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
$user='hassan';
$apple ="6217c55b626e7477b972034993b40a29";
$salt="231**6";
$uname= $_POST["uname"];
$pas= $_POST["psw"];
$token1= hash("ripemd128", '$salt$pas');
if($token1===$apple && $user===$uname)
{
$_SESSION["user"]= $user;
echo $_SESSION["user"];
if ($_SESSION["user"] == $user && $token1===$apple)
{
echo "Welcome ".$_SESSION["user"];
}
?>
<h1>you are logged in</h1>
<form action="inbox.php" class="boxed" style ="border: 4px solid black ; text-align: center; method="post">
<h1><b>Check inbox :</b></h1>
<input type="submit" class="button" value="Inbox" style =" background-color: grey;
border: none;
color: white;
padding: 15px 70px;
margin: 15px 0px;
cursor: pointer;"><br><br>
</form>
<form action="add.php"class="boxed" style ="border: 4px solid black ; text-align: center; method="post">
<h1><b>ADD propert :</b></h1>
<input type="submit" value="ADD" style =" background-color: grey;
border: none;
color: white;
padding: 15px 70px;
margin: 15px 0px;
cursor: pointer;">
</form>
<form action="logout.php" class="boxed" style ="border: 4px solid black ; text-align: center; method="post">
<h1>logout here</h1>
<input type="submit" class="button" value="Logout" style =" background-color: grey;
border: none;
color: white;
padding: 15px 70px;
margin: 15px 0px;
cursor: pointer;">
</form>
<?php
$_SESSION["user"]= "null";
$token=null;
$user=null;
}
else
{
?>
<h1>You entered wrong details please enter again</h1>
<a href="admin.html">try again</a>
<?php
}
?>
</body>
</html>
로그인 및 로그 아웃에 문제가 있습니다. 세션은 유지 보수 중이지만 여전히 잘못된 세부 사항을 기록합니다. 해시와 소금을 모두 사용하여 암호를 암호화 한 다음 변수 apple
에 저장했습니다. 내 가난한 들여 쓰기 죄송합니다. 나는 PHP를 처음 사용합니다. 로그인하면 내 스크립트는 세 가지 기능을 수행합니다. 모두 작동하지만 로그 아웃도 실패합니다.로그인/로그 아웃이 제대로 작동하지 않습니다.
저는이 문제에 봉착했습니다. 이미 이미 기한이 지난 프로젝트에이를 제출해야하므로 도움이 될 것입니다.
잘못된 세부 정보로 어떻게 로그인 할 수 있습니까? 이 코드는 한 사용자에 대해서만 설정되어 있습니다. – Rager