how would i fix my code, any login doesnt work but it should retrieve it from the table table: user hw1.php code: <?php // Start the session // If the user is not logged in, redirect to the login page if (!isset($_COOKIE['userid']) || !isset($_SESSION['userid'])) { header('Location: hwlogin.php'); } ?> <!DOCTYPE html> <html> <head> <title>Protected Page</title> </head> <body> <h1>Welcome to the protected page</h1> </body> </html> hw1login.php code: <?php // Start the session session_start(); // Connect to the database $conn = new mysqli('localhost', '<database>', '<username>', '<password>'); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // If the form has been submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Get the username and password from the form $username = $_POST['username']; $password = $_POST['password']; // Prepare the SQL query to check if the user exists $stmt = $conn->prepare('SELECT id FROM user WHERE username = ? AND password = ?'); $stmt->bind_param('ss', $username, $password); $stmt->execute(); $stmt->store_result(); // If the user exists, set a cookie named "userid", store the user ID in the session, and redirect to the hw1.php page if ($stmt->num_rows > 0) { $stmt->bind_result($id); $stmt->fetch(); setcookie('userid', $id, time() + (86400 * 30), "/"); $_SESSION['userid'] = $id; header('Location: hw1.php'); exit; } else { $error = 'Incorrect username or password'; header('Location: hw1login.php'); exit; } } ?> <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <h1>Login</h1> <?php if (isset($error)) { ?> <p><?php echo $error; ?></p> <?php } ?> <form method="post"> <label>Username:</label> <input type="text" name="username"><br> <label>Password:</label> <input type="password" name="password"><br> <input type="submit" value="Login"> </form> </body> </html> .