World English Institute
<?php session_start(); // ----- DATABASE CONFIG ----- $conn = mysqli_connect("localhost","root","","wei_db"); if(!$conn){ die("DB Error: ".mysqli_connect_error()); } // ----- LOGIN ----- if(isset($_POST['login'])){ $user = $_POST['user']; $pass = $_POST['pass']; $res = mysqli_query($conn,"SELECT * FROM users WHERE name='$user' AND password='$pass'"); if(mysqli_num_rows($res)>0){ $row = mysqli_fetch_assoc($res); $_SESSION['user'] = $row['name']; $_SESSION['role'] = $row['role']; header("Location: index.php"); exit(); } else { $error = "Wrong username or password!"; } } // ----- LOGOUT ----- if(isset($_GET['logout'])){ session_destroy(); header("Location: index.php"); exit(); } // ----- ADMIN: CREATE LESSON ----- if(isset($_POST[...