Файловый менеджер - Редактировать - /home/carpe/public_html/starship/login.php
Назад
<?php session_start(); include 'database.php'; $database = new Database(); $connexion = $database->getConnection(); if ($connexion) { $error = 0; $erreur = ""; if(isset($_POST['send'])){ header("Location: login.php"); if(empty($_POST['username']) OR empty($_POST['password'])){ $erreur = 'Veuillez remplir tous les champs !'; newCookie($erreur); }else{ $username = addslashes($_POST['username']); $password = addslashes($_POST['password']); $sql = "SELECT * FROM users"; $statement = $connexion->prepare($sql); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { $username2 = $row["username"]; $password2 = $row["password"]; if($username == $username2 AND password_verify($password, $password2)){ $_SESSION['login']= $username; header("Location: univers.php"); }else{ $error ++; } } } } if($error>0){ $erreur = "<div class='errore'>Mot de passe et/ou nom d'utilisateur incorrect</div>"; newCookie($erreur); } }else{ echo "Connexion à la base de donnée échouée."; } if(isset($_POST['register'])){ header("Location: register.php"); } function newCookie($erreur){ $nom = "resultat"; $valeur = $erreur; $expire = time() + (30 * 24 * 60 * 60); setcookie($nom, $valeur, $expire, "/"); } ?> <!DOCTYPE html> <html> <head> <title>Starship</title> <meta charset="utf-8"> </head> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Nabla&family=Quicksand:wght@300..700&family=VT323&display=swap" rel="stylesheet"> <style> body{ background:black; width:100%; height:100vh; display:flex; justify-content:center; align-items:center; padding:0; margin:0; color:white; } #contain{ width:800px; height:500px; background:#F2F2F2; background:black; display:flex; justify-content:center; align-items:center; border: 5px solid #d0c2c2; } #start_menu{ display:flex; justify-content:center; align-items:center; flex-wrap:wrap; width:400px; } #start_menu img{ width:100%; } form label{ color:#d0c2c2; font-family: "VT323", monospace; font-size:1.5rem; } form div{ display:flex; justify-content:space-between; margin:20px; gap:20px } form div input{ background:#d0c2c2; outline:none; border:none; font-family: "VT323", monospace; font-size:1.5rem; } #last{ margin-top:40px; justify-content:space-around; } #last input{ color:black; font-family: "VT323", monospace; font-size:1.5rem; border:none; background:#d0c2c2; padding:5px 10px 5px 10px; border-radius:1px; transition:.5s all; cursor:pointer; } #last input:hover{ transform:scale(1.05); transition:.5s all; } .errore{ color:#d0c2c2; font-family: "VT323", monospace; } h1{ color:#d0c2c2; font-family: "VT323", monospace; margin:0; padding:0; font-size:1.5rem; width:100%; text-align:center; } </style> <body> <div id='contain'> <div id='start_menu'> <img id='logo' src="images/logo.png"> <h1>Connexion : </h1> <?php if(isset($_COOKIE['resultat2'])){ setcookie("resultat2", "", time() - 3600, "/"); } if (isset($_COOKIE['resultat'])) { echo "<div class='errore'>"; echo $_COOKIE['resultat']; echo "</div>"; setcookie("resultat", "", time() - 3600, "/"); } ?> <form method='POST' action='login.php'> <div> <label>Pseudo : </label> <input type='text' name='username'> </div> <div> <label>Mot de passe : </label> <input type='password' name='password'> </div> <div id='last'> <input type='submit' name='register' value='Créer un compte' > <input type='submit' name='send' value='Valider' > </div> </form> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка