Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/ovning5/

index.html
ovn_str1.php
ovn_str2.php
ovn_str3.php
ovn_str4.php
ovn_str5.php
ovn_str6.php
svar.php
svar2.php
svar3.php
svar4.php
svar5.php

ovn_str6.php

51 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form method="post" action="">
        <label for="text">Text</label>
        <input type="textarea" name="text"> <br>
        <input type="submit" value="Skicka">
    </form>
    <?php
    
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
        
$text $_POST["text"];
        
$newtext "";
        for (
$i 0$i strlen($text); $i++){
            if (
$text[$i] == "b"||
                
$text[$i] == "c"||
                
$text[$i] == "d"||
                
$text[$i] == "f"||
                
$text[$i] == "g"||
                
$text[$i] == "h"||
                
$text[$i] == "j"||
                
$text[$i] == "k"||
                
$text[$i] == "l"||
                
$text[$i] == "m"||
                
$text[$i] == "n"||
                
$text[$i] == "p"||
                
$text[$i] == "q"||
                
$text[$i] == "r"||
                
$text[$i] == "s"||
                
$text[$i] == "t"||
                
$text[$i] == "v"||
                
$text[$i] == "w"||
                
$text[$i] == "x"||
                
$text[$i] == "z"
            
){
                
$newtext .= $text[$i]. "o"$text[$i];
            }
            else {
                
$newtext .= $text[$i];
            }
        }
        echo 
"<br>"$text"<br> <br>";
        echo 
$newtext;
    }
    
?>
</body>
</html>