<?
php
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];
// Connect to your MySQL database
$host = "[Link]";
$db_username = "if0_34849447";
$db_password = "------------";
$db_name = "if0_34849447_umbrella_corp";
$conn = new mysqli($host, $db_username, $db_password, $db_name);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch user from the database
$query = "SELECT * FROM users WHERE username = '$username'";
$result = $conn->query($query);
if ($result->num_rows == 1)
{
$user = $result->fetch_assoc();
echo "Fetched password from database: " . $user["passwordz"] .
"<br>";
//echo "Input password: " . $password . "<br>";
echo "Fetched password from database: " . $user["namez"] . "<br>";
echo "Fetched password from database: " . $user["idz"] . "<br>";
// echo "Fetched password from database: " . $user["sec"] .
"<br>";
$name= $user["namez"];
$userid= $user["idz"];
// $usersec= $user["sec"];
// Verify the password
if ($user["password"]==$_POST["password"])
{
// Password is correct, set up a session and redirect to the
dashboard
$_SESSION["namez"] = $name;
$_SESSION["idz"] = $userid;
// $_SESSION["sec"] = $usersec;
header("Location: [Link]"); // NAME SA INYONG MAIN PAGE
exit();
}
else
{
$error_message = "Invalid password.";
}
} else {
$error_message = "Invalid username.";
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Result</title>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body>
<div class="login-container">
<h2>Login Result</h2>
<?php if (isset($error_message)) { ?>
<p style="color: red;"><?php echo $error_message; ?></p>
<?php } ?>
<p><a href="[Link]">Back to Login</a></p>
</div>
</body>
</html>