Webbsrv 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/

ovning1.php
ovning2.php
ovning3/
ovning4.php
ovning4_post.php
ovning5.php

ovning4_post.php

36 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

if (isset($_POST["form1"])) {
  
$namn = htmlspecialchars($_POST["namn"]);
  echo 
"Hjärtligt välkommen " . $namn . "!";
}

if (isset(
$_POST["form3"])) {
  
$fornamn = htmlspecialchars($_POST["fnamn"]);
  
$efternamn = htmlspecialchars($_POST["enamn"]);
  
$klass = htmlspecialchars($_POST["klass"]);
  
$mat = htmlspecialchars($_POST["mat"]);

  echo 
"Hej " . $fornamn . " " . $efternamn . " i " . $klass . "! Du gillar " . $mat . "!";
}

if (isset(
$_POST["form4"])) {
  
$kurs = htmlspecialchars($_POST["kurs"]);
  
$meddelande = "Du favoritkurs är: " . $kurs . "!";
  echo 
$meddelande;

  
$mottagare = "majham25@varmdogymnasium.se";
  
$rubrik = "Svar från formulär";
  
$header = "From: webb@noreply.se\r\n";
  
$header .= "Content-Type: text/plain; charset=UTF-8\r\n";

  
mail($mottagare, $rubrik, $meddelande, $header);
}

?>