<?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