Created
September 1, 2018 07:49
-
-
Save makzan/878f5abf58c89ff533610e748eacb0de to your computer and use it in GitHub Desktop.
Example code for PHP class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// DATA | |
$passwords = [ | |
"John" => "1357", | |
"Susan" => "2468", | |
"Steven" => "1890", | |
"Steve" => "9876" | |
]; | |
// LOGIC | |
$lastname = $_POST["lastname"] ?? ""; | |
$password = $passwords[$lastname] ?? ""; | |
// INTERFACE | |
?> | |
<h1>Welcome <?= $lastname ?>.</h1> | |
<?php if ($password != ""): ?> | |
<p>Your Wi-Fi password is <?= $password ?>.</p> | |
<?php endif; ?> | |
<form method="POST" action=""> | |
Please enter your last name: | |
<input type="text" name="lastname"> | |
<input type="submit"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment