<?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新手。登錄後,我的腳本將執行三個功能 - 全部正在工作,但註銷也失敗。登錄/註銷無法正常工作的PHP
我堅持這一點,我需要提交這個項目已經是一天過期,所以任何幫助將不勝感激!
如何以錯誤的細節登錄?此代碼僅適用於一位用戶。 – Rager