prepare($sql); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $user = $result->fetch_assoc(); if (password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; header("Location: home.php"); exit; } else { echo "Invalid credentials!"; } } else { echo "User not found!"; } } else { echo "Database connection error!"; } }