1

Temat: PHP - hasło

<!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 action="" method="post">
    <p>Imię: <input type="text" name="imie" value="Jan"></p>
    <p>Nazwisko: <input type="text" name="nazwisko" value="Nowak"></p>
    <p><input type="checkbox" name="haslo" value="1" checked> Wygeneruj hasło</p>
    <p><input type="submit" value="Inicjały"></p>
    </form>

    <?php
        if (!empty($_POST))
        {
            if (isset($_POST['imie'])) $imie=$_POST['imie']; else $imie="";
            if (isset($_POST['nazwisko'])) $nazwisko=$_POST['nazwisko']; else $nazwisko="";
            if (isset($_POST['haslo'])) $haslo=(int)$_POST['haslo']; else $haslo=0;
            //
            $in=$imie[0].$nazwisko[0];
            // substr($tekst, 0, 7);
            echo "<h1>".$in."<h1>";
            if ($haslo)
            {
              $losuj=50+rand(0, 49);
              $male=strtolower($in);
              echo "<h1>".$in.$losuj.$male."</h1>";   
            }
        }
    ?>
</body>
</html>