現在我想做一個登錄系統。如果用戶存在,我想檢查表管理員,如果是這種情況,讓他登錄。我沒有編碼系統登錄,但它不起作用。任何建議或解決方案是受歡迎的登錄系統,讀取身份和密碼,然後登錄
問候A.V
<?php
ob_start();
session_start();
?>
<html lang="en">
<head>
<title>Foredeck Login.com</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #6495ED;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
color: #000000;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: 0 px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
border-color: #000000;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-color: #000000;
}
h3 {
text-align:;
color: #000000;
}
h1 {
text-align:;
color: #000000;
}
</style>
</head>
<body>
<div class="container form-signin">
<?php
include("bdconnect_Foredeck.php");
$link=Mysqli_connect($host,$login,$pass,$dbname);
$msg = '';
if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) {
$Identifiant = $_POST['username'];
$MotPasse = $_POST['password'];
$recherche= "SELECT * FROM admin WHERE Identifiant ='$Identifiant' And Mdp_Admin='$MotPasse'";
mysqli_query($link,$recherche);
$result= mysqli_query($link,$recherche);
while($row = mysqli_fetch_assoc($result)){
$Identifiant = $row["Identifiant_Admin"];
$MotPasse = $row["Mdp_Admin"];
}
if ($_POST['username'] == $Identifiant['username'] && $_POST['password'] == $MotPasse['password']) {
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['username'] = 'foredeckadmin';
$msg ='Connexion Réussite';
echo "
<script type='text/javascript'>
alert('Connexion Réussite');
window.location = 'foredeck.php';
</script>";
header("refresh:3 location: foredeck.php");
}
else if ($_POST['username'] == 'Isabelle' && $_POST['password'] == 'Isabelle1'){
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['username'] = 'foredeckadmin';
$msg ='Connexion Réussite';
echo "
<script type='text/javascript'>
alert('Connexion Réussite');
window.location = 'foredeck_superadmin.php';
</script>";
header("refresh:3 location: foredeck_superadmin.php");
}
else {
$msg='Identifiant ou Mot de Passe incorrecte';
$msg = "
<script type='text/javascript'>alert('$msg')</script>";
}
}
?>
</div> <!-- /container -->
<div class="container">
<form class="form-signin" role="form" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<h4 class="form-signin-heading"><?php echo $msg; ?></h4>
<h1>[email protected]</h1>
<h3>Entrer l'identifant et le mot de passe:</h3>
<input type="text" class="form-control" name="username" placeholder="Identifiant " required autofocus><br/>
<input type="password" class="form-control" name="password" placeholder="Mot de passe" required>
<br>
<button class="btn btn-lg btn-primary btn-block" type="submit" name="login">
Se connecter
</button>
</form>
</div>
</body>
</html>
而不是'Mdp_Admin ='MotPasse''對不對? – affaz
以及我想我需要存儲變量來比較它們登錄的權利? [一個幫助截圖](https://cdn.discordapp.com/attachments/240225788715204609/280663850485940224/unknown.png) –
這可能是非常有用的:http://stackoverflow.com/questions/34358552/login-system- with-mysqli –