Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
CREATE DATABASE test; USE test; CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL UNIQUE, email VARCHAR(100) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP );

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php require 'config.php'; if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) { redirect('login.php'); } ?> <!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Главная страница</title> <style> body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } .welcome { margin-bottom: 20px; } .logout { color: red; text-decoration: none; } .logout:hover { text-decoration: underline; } </style> </head> <body> <div class="welcome"> <h2>Добро пожаловать, <?= htmlspecialchars($_SESSION['username']) ?>!</h2> <p>Вы успешно вошли в систему.</p> <a href="logout.php" class="logout">Выйти</a> </div> <div class="content"> <h3>Это ваша главная страница</h3> <p>Здесь может быть любой контент, доступный только авторизованным пользователям.</p> </div> </body> </html>
Copy Clear