Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <?php
- // Start the session
- session_start();
- // Connessione al DB
- $dbconn = pg_pconnect("host=localhost port=5432 dbname=postgres user=postgres password=Fleabasser96")
- or die('Could not connect: ' . pg_last_error());
- // User e psw = post
- $username = $_POST['username'];
- $password = $_POST['password'];
- // Log-in query e variabile di controllo
- $sql_log = "SELECT email,password FROM public.utenti WHERE email='$username' AND password='$password'";
- $success = false;
- // Messaggio stampato sotto a button
- $error = "";
- // Se già loggato rimanda a account
- if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {
- $error = "success";
- header('Location: account.php');
- }
- // Se sono state inserite le credenziali
- //controllo se esiste un elemento trasformando success a true
- //se è true loggo
- //se è false modifico la stringa da stampare
- if (isset($_POST['username']) && isset($_POST['password'])) {
- $result = pg_query($dbconn, $sql_log);
- while($row = pg_fetch_row($result)) {
- $success = true;
- }
- if($success == true) {
- $_SESSION['loggedIn'] = true;
- header('Location: account.php');
- $error = "Valid credentials!";
- } else {
- $_SESSION['loggedIn'] = false;
- $error = "Invalid username or password!";
- }
- pg_free_result($result);
- pg_close($dbconn);
- /*
- if ($_POST['username'] == $username && $_POST['password'] == $password) {
- $_SESSION['loggedIn'] = true;
- header('Location: account.php');
- } else {
- $_SESSION['loggedIn'] = false;
- $error = "Invalid username and password!";
- }*/
- }
- ?>
- <html>
- <head>
- <title>DoungeonAsDB : Official</title>
- <?php include ('lib/header.php'); ?>
- </head>
- <body>
- <div class="background-wrap">
- <video id="bgvideo" preload="auto" autoplay="true" loop="loop" muted="muted" poster="">
- <source src="video.mov" type="video/mp4">
- </video>
- </div>
- <div class="content">
- <h1>Dungeon As DB</h1>
- <div id="log">
- <form method="post" action="index.php">
- <label for="username">Email</label><br>
- <input class="inputborder" type="text" name="username" id="username" placeholder="Enter Email" required>
- <br><br>
- <label for="password">Password</label><br>
- <input class="inputborder" type="password" name="password" id="password" placeholder="Enter Password" required>
- <br>
- <button type="submit">Login</button>
- <br>
- <?php
- echo "<p style='color:white;'>".$error."</p>";
- ?>
- <div class ="register">
- <span class="psw">New to DoungeonASDB? <a href="register.php"> Sign Up Now. </a></span>
- </div>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement