prepare('SELECT id, jelszo FROM fiokok WHERE email = ?')) { // Bind parameters (s = string, i = int, b = blob, etc), in our case the username is a string so we use "s" $stmt->bind_param('s', $_POST['email']); $stmt->execute(); // Store the result so we can check if the account exists in the database. $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($id, $password); $stmt->fetch(); // Account exists, now we verify the password. // Note: remember to use password_hash in your registration file to store the hashed passwords. if (password_verify($_POST['password'], $password)) { // Verification success! User has logged-in! // Create sessions, so we know the user is logged in, they basically act like cookies but remember the data on the server. session_regenerate_id(); $_SESSION['loggedin'] = TRUE; $_SESSION['name'] = $_POST['email']; $_SESSION['id'] = $id; echo 'Üdvözlöm ' . $_SESSION['name'] . '!'; } else { // Incorrect password echo 'Helytelen felhasználónév vagy jelszó!'; } } else { // Incorrect username echo 'Helytelen felhasználónév vagy jelszó!'; } $stmt->close(); } ?>