Skip to content

Instantly share code, notes, and snippets.

@zelon88
Created October 8, 2016 15:29
Show Gist options
  • Save zelon88/0f6617b755291752122c65c16a2ccd3e to your computer and use it in GitHub Desktop.
Save zelon88/0f6617b755291752122c65c16a2ccd3e to your computer and use it in GitHub Desktop.
<form action="TeachingKids.php" method="post">
<p>Name: <input type='text' id='name' name='name' value=''>
<input type="submit"></p>
</form>
<p>
<?php
// Teaching my kids how to code.
$name = $_POST['name'];
$awesomeboys = array('boy', 'dad');
$coolgirls = array('girl', 'mom');
if (in_array($name, $awesomeboys)) {
echo 'You are an awesome boy!'; }
if (in_array($name, $coolgirls)) {
echo 'You are a cool girl!'; }
if (!in_array($name, $awesomeboys) && !in_array($name, $coolgirls)) {
echo 'I don\'t know you '.$name.'!'; }
?>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment