Changes to some things
This commit is contained in:
		@@ -1,3 +1,35 @@
 | 
			
		||||
<?php
 | 
			
		||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
 | 
			
		||||
    // Handle login form submission
 | 
			
		||||
    $email = $_POST['email'];
 | 
			
		||||
    $password = $_POST['password'];
 | 
			
		||||
 | 
			
		||||
    // Validate login credentials and fetch user details
 | 
			
		||||
    $query = "SELECT id, username, password, email, isAdmin FROM users WHERE email = ?";
 | 
			
		||||
    $stmt = $mysqli->prepare($query);
 | 
			
		||||
    $stmt->bind_param("s", $email);
 | 
			
		||||
    $stmt->execute();
 | 
			
		||||
    $stmt->bind_result($user_id, $user_username, $user_password, $user_email, $user_isAdmin);
 | 
			
		||||
 | 
			
		||||
    // Fetch the result
 | 
			
		||||
    if ($stmt->fetch() && password_verify($password, $user_password)) {
 | 
			
		||||
        $_SESSION['user_id'] = $user_id;
 | 
			
		||||
        $_SESSION['user_username'] = $user_username;
 | 
			
		||||
        $_SESSION['user_email'] = $user_email;
 | 
			
		||||
        $_SESSION['user_isAdmin'] = $user_isAdmin;
 | 
			
		||||
 | 
			
		||||
        // Redirect to the main domain after successful login
 | 
			
		||||
        header('Location: http://watch.twip-network.org');
 | 
			
		||||
        exit();
 | 
			
		||||
    } else {
 | 
			
		||||
        echo "Invalid email or password.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Close the statement
 | 
			
		||||
    $stmt->close();
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<h2>Login</h2>
 | 
			
		||||
<form action="login.php" method="post">
 | 
			
		||||
    <input type="email" name="email" id="email-field" placeholder="E-Mail" required>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								pages/global/logout.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								pages/global/logout.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
session_start();
 | 
			
		||||
session_destroy();
 | 
			
		||||
header('Location: /');
 | 
			
		||||
exit();
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user