Webbserverprogrammering 1

Källkod

Följande filer och mappar finns under mappen webbserverprogrammering.
Mappar visas till vänster och filer till höger. Klicka på en fil eller mapp för att öppna nedan eller visa dess innehåll.

webbserverprogrammering/exercises/cookies_and_sessions/

7 filer

cookies_sessions_1.php
cookies_sessions_2.php
cookies_sessions_3.php
cookies_sessions_3_secret.php
cookies_sessions_4.php
cookies_sessions_5.php
cookies_sessions_5_mail.php

cookies_sessions_3.php

44 lines UTF-8 Windows (CRLF)
<?php
error_reporting
(-1); // Report all type of errors
ini_set('display_errors'1); // Display all errors 
ini_set('output_buffering'0); // Do not buffer outputs, write directly
?>

<?php
session_start
();
$warningMsg "";
if (isset(
$_POST["username"]) && isset($_POST["password"])) {
 if (
$_POST["username"] === "alrikmz" && $_POST["password"] === "lingonSKOGEN") {
  
$_SESSION["loggedIn"] = true;
  
header("Location: cookies_sessions_3_secret.php");
 }
 else
  
$warningMsg "Wrong login!<br>";
}

?>

<!DOCTYPE html>
<html lang="sv">
<head>
 <title>Session 3</title>
 <meta charset="utf-8">
 <style type="text/css">
  body {
   font-family: Arial;
  }
 </style>
</head>
<body>

 <h1>Inloggning</h1>
 <form method="post" action="">
  <?php echo "$warningMsg"?>
  <input type="text" name="username" placeholder="Användarnamn" required><br>
  <input type="password" name="password" placeholder="Lösenord" required><br>
  <br>
  <input type="submit" name="submitted">
 </form>

</body>
</html>