Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/textsträngar/

index.php
ovn_str1.php
ovn_str2.php
ovn_str4.php
ovn_str5.php
ovn_str6.php

ovn_str2.php

49 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>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>STRÄNGHANTERING</title>
</head>

<body>

    <?php

    
if (isset($_POST["userName"])) { // Behöver bara checka en variabel
        
$userName $_POST["userName"];
        
$passWord $_POST["password"];

        
$valid true;
        if (
mb_strPos($userName"php") === false){
            
$valid false;
        }
        echo (
"<br>");
        if (
mb_strlen($passWord) < 6){
            
$valid false;
        }
        if(
$valid){
            echo(
"Perfa, snyggt jobbat");
        } else{
            echo(
"Haha du skrev fel");
        }
    }
    
?>
    <form method="POST">
        <input type="text" name="userName" id="user_id" placeholder="harryphp" required>
        <label for="user_id">Användarnamn som innehåller "php"</label><br>
        <input type="text" name="password" id="pswrd_id" placeholder="lösenord123" required>
        <label for="pswrd_id">Lösenord (minst 6 bokstäver)</label><br>
        <button type="submit">Skicka in</button>
    </form>

</body>

</html>