Skip to content

Instantly share code, notes, and snippets.

@makzan
Created September 1, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makzan/878f5abf58c89ff533610e748eacb0de to your computer and use it in GitHub Desktop.
Save makzan/878f5abf58c89ff533610e748eacb0de to your computer and use it in GitHub Desktop.
Example code for PHP class
<?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