JAVA Intro2
JAVA Intro2
session_start();
// Database credentials
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "phpcrud";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$stmt->bind_param("s", $username);
// Verify password
if (password_verify($password, $password)) {
// Password is correct, start a new session
$_SESSION['user_id'] = $id;
$_SESSION['username'] = $username;
header("Location: index.php"); // Redirect to index.php
exit();
} else {
// Password is incorrect
echo "Invalid password.";
}
} else {
// No user found with that username
echo "No user found with that username.";
}