Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include 'layout.php'; ?>
- <head>
- <title>Login</title>
- </head>
- <link rel="stylesheet" href="/custom_CSS/loginCSS.css" type="text/css" />
- <body>
- <h1>
- Login
- </h1>
- <div class="loginForm">
- <form method="post">
- <p class="login_prompt">Login using your username and password.</p>
- <input type="text" name="username" placeholder="Username"><br /><br />
- <input type="password" name="password" placeholder="Password"><br />
- <label id="remembermeLabel">Remember me</label>
- <input type="checkbox" name="remembermecheck" value="remember"><br />
- <input type="submit" name="loginButton" value="Login" />
- </form>
- <?php
- session_start();
- require 'connectDB.php';
- if(!empty($_POST['username']) && !empty($_POST['password']))
- {
- $hashpassword = hash('sha512', $_POST['password']);
- $sql = 'SELECT userID, name, username FROM user WHERE username = "'.$_POST['username'].'" AND password = "'.$hashpassword.'";';
- $result = $conn->query($sql);
- if(mysqli_num_rows($result) == 1)
- {
- $row = $result->fetch_assoc();
- $_SESSION['user_id'] = $row['userID'];
- header("Location: index.php");
- }
- else
- {
- $message = "Error";
- echo "$message";
- }
- }
- ?>
- </div>
- </body>
Add Comment
Please, Sign In to add comment