PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
<?php session_start(); if (!isset($_SESSION["username"])) { header("location: login.html"); } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Include necessary head elements and styles --> </head> <body> <header> <h1>Welcome, <?php echo $_SESSION["username"]; ?></h1> </header> <nav> <!-- Dashboard navigation links --> </nav> <section> <!-- Dashboard content --> </section> <footer> <p>&copy; 2023 Your Website</p> </footer> </body> </html>
Copy Clear
Copy Format Clear
<?php session_start(); include("config.php"); if ($_SERVER["REQUEST_METHOD"] == "POST") { $username = $_POST["username"]; $password = $_POST["password"]; $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $result = $conn->query($sql); if ($result->num_rows == 1) { $_SESSION["username"] = $username; header("location: dashboard.php"); } else { echo "Invalid username or password"; } } $conn->close(); ?>
Show:  
Copy Clear