D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
proc
/
self
/
root
/
home
/
markniuj
/
.vscode-server
/
data
/
User
/
History
/
3c29388f
/
Filename :
kaSW.php
back
Copy
<?php include "../config.php"; // Start a PHP session session_start(); // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get form data $username = $_POST["username"]; $password = $_POST["password"]; // Validate the user credentials $sql = "SELECT * FROM users WHERE username = '$username'"; $result = $conn->query($sql); if ($result->num_rows == 1) { // User found, verify password $row = $result->fetch_assoc(); if (password_verify($password, $row['password'])) { // Password is correct, set session and redirect to dashboard or home page $_SESSION['username'] = $username; header("Location: dashboard.php"); // Change this to your dashboard page exit(); } else { // Incorrect password $error = "Incorrect password"; } } else { // User not found $error = "User not found"; } // Redirect back to login with error message header("Location: login.php?error=" . urlencode($error)); exit(); } else { // Redirect to login page if accessed directly without form submission header("Location: login.php"); exit(); } // Close the database connection $conn->close(); ?>