Username: " . $username ."\n

"; echo "

Password: " . $password . "



"; $_SESSION['logged_in'] = true; $_SESSION['CSRFToken'] = bin2hex(random_bytes(32)); } function logout() { if (session_status() == PHP_SESSION_NONE) { session_start(); } $_POST = array(); $_SESSION = array(); // Tömmer sessionsarrayen session_regenerate_id(true); $_SESSION['CSRFToken'] = bin2hex(random_bytes(32)); } function cleanData($data) { $data = strip_tags($data); $data = htmlspecialchars($data); $data = trim($data); $data = stripslashes($data); return $data; } ?> M4 | 04
Form >



Logged in!"; } else { echo "

Not logged in!

"; } if(isset($_POST['message'])) { if($_SESSION['CSRFToken'] === $_POST['CSRFToken']){ echo "ok csrft"; }else{ echo "Inte ok csrft"; } $safeName = filter_input(INPUT_POST, 'name',FILTER_SANITIZE_FULL_SPECIAL_CHARS); $safeMassage = filter_input(INPUT_POST, 'text',FILTER_SANITIZE_FULL_SPECIAL_CHARS); echo "

Name - " . $safeName . "

"; echo "

Massage - " . $safeMassage . "

"; } else { echo "

No message!

"; } ?> Login