Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //require_once ("config.php");
- //ob_start();
- session_start();
- //$error = false;
- //$msg = '';
- //$username=$_POST['username'];
- //$password=$_POST['password'];
- //$query = $DBH->prepare("SELECT * FROM Users WHERE Nickname='$username' and Passwrd='$password'");
- if (isset($_POST['submit'])) {
- include_once ('config.php');
- $username = $_POST['username'];
- $password = $_POST['password'];
- //error jutut
- //tyhjät kohdat
- if (empty($username) || empty($password)) {
- header("Location: index.html?login=empty");
- exit();
- } else {
- $sql = "SELECT * FROM Users WHERE Nickname='$username'";
- $param = array('username' => $username);
- $query = $DBH->prepare($sql);
- $query->execute($param);
- $row = $query->fetch();
- if ($query-> rowCount == 0 ) {
- header("Location: index.html?login=error");
- exit();
- //dehässäys salasanalle
- } else {
- if ()
- $hashpasswordcheck = password_verify($password, $row['password']);
- if ($hashpasswordcheck == false) {
- header("Location: index.html?login=error2");
- exit();
- } elseif ($hashpasswordcheck == true) {
- //login
- $_SESSION['username']= $row['username'];
- $_SESSION['email']= $row['email'];
- header("Location: index.html?login=success");
- exit();
- }
- }
- }
- } else {
- header("Location: index.html?login=errorSOS");
- exit();
- }
Add Comment
Please, Sign In to add comment