Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/

cookie.php
extra.php
formulär.php
index (2).php
index.php
inklud1.php
inklude/
inklude2.php
inlogg.php
medeltal.php
ovn_1.php
ovn_2.php
ovn_4.php
resultat.php
resultat2.php
resultat3.php
session.php
sid1.php
sid2.php
sid3.php
sidslut.php
sidstart.php
textfeedback.php
textstreng.php
valkommen.php

textfeedback.php

54 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <title>Feedback</title>
</head>
<body>
    <?php
        $fornamn 
= ucfirst(strtolower($_POST["fornamn"]));
        
$efternamn = ucfirst(strtolower($_POST["efternamn"]));
        
$epost = $_POST["epost"];

        
$godkand = true;

    if (
strlen($epost) < 6) {
        
$godkand = false;
    }

    
$position = strpos($epost, "@");

    if (
$position === false) {
        
$godkand = false;
    } else {
        
$efterAt = substr($epost, $position + 1);

        if (
strlen($efterAt) < 4) {
            
$godkand = false;
        }

        
$punkt = strpos($efterAt, ".");

        if (
$punkt === false) {
            
$godkand = false;
        } elseif (
$punkt >= strlen($efterAt) - 2) {
            
$godkand = false;
        }
    }

    echo 
"Förnamn: " . htmlspecialchars($fornamn) . "<br>";
    echo 
"Efternamn: " . htmlspecialchars($efternamn) . "<br>";
    echo 
"E-postadress: " . htmlspecialchars($epost) . "<br><br>";

    if (
$godkand) {
        echo 
"E-postadressen är godkänd!";
    } else {
        echo 
"E-postadressen är inte godkänd.";
    }
    
?>

    <br><br>
    <a href="textstreng.php">Tillbaka</a>

</body>
</html>