<?php session_start(); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $connect = new mysqli('localhost', 'username', 'password', 'db_name'); $connect->set_charset('utf8mb4'); // always set the charset if (isset($_POST['user_name'], $_POST['user_pass']) && $_POST['user_login'] == 1) { //Assigning posted values to variables. $username = $_POST['user_name']; $password = $_POST['user_pass']; //Checking the values are existing in the database or not $stmt = $connect->prepare("SELECT user_pass FROM users WHERE user_name=?"); $stmt->bind_param('s', $username); $stmt->execute(); $result = $stmt->get_result(); $user_from_db = $result->fetch_object(); if ($user_from_db && password_verify($password, $user_from_db->user_pass)) { $_SESSION['pageadmin'] = true; $_SESSION['user_name'] = $username; } else { //If the login credentials doesn't match, he will be shown with an error message. echo "Invalid Login Credentials."; } }
You have javascript disabled. You will not be able to edit any code.