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/strings/

11 filer

strings_1.php
strings_1_formreceive.php
strings_2.php
strings_2_formreceive.php
strings_3.php
strings_3_formreceive.php
strings_4.php
strings_4_formreceive.php
strings_5.php
strings_5_formreceive.php
strings_6.php

strings_1_formreceive.php

40 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
?>

<!DOCTYPE html>
<html lang="sv">
<head>
 <title>Texsträngar 1, formulärinfo</title>
 <meta charset="utf-8">
 <style type="text/css">
  body {
   font-family: Arial;
  }
 </style>
</head>
<body>
 <?php
 $firstname 
$_POST["firstname"];
 
$surname $_POST["surname"];
 
$email $_POST["email"];

 
$firstname ucfirst(mb_strtolower($firstname));
 
$surname ucfirst(mb_strtolower($surname));
 
$emailOK mb_strpos($email"@");
 
 
// Below if means: it's not false, meaning position is 0-X (X = string length), set to true
 // If 0 and left so, then shorthand if below interprets as "false" which it should not
 
if ($emailOk !== false)
  
$emailOk true;
 echo 
"<strong>Förnamn:</strong> $firstname<br><strong>Efternamn:</strong> $surname<br><strong>E-post:</strong> $email<br><br>";
 echo 
$emailOK "Epostadressen innehåller snabel-a, <strong>bra!</strong>" "Epostadressen innehåller <strong>inte</strong> snabel-a, <strong>dåligt!</strong>";
 
?>
 <br>
 <br>
 <br>
 <a href="strings_1.php">Tillbaka</a>
</body>
</html>