-
Notifications
You must be signed in to change notification settings - Fork 0
/
unicorn.php
30 lines (17 loc) · 998 Bytes
/
unicorn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
//In a new file unicorn.php, create an html form asking "Are you a human, a cat or a unicorn ?". When submitted, the screen displays an animated Gif showing either a human, a cat or a unicorn, as per the user input (you can find gifs here). Use GET or POST as method, whichever you like. Use a ternary operation to evaluate the condition.
?>
<p style="color: blueviolet;">"Are you a human, a cat or a unicorn ?"</p>
<form method="get" action="">
<label for="image">...</label>
<input type="" name="image">
<input type="submit" name="submit" value="Choose">
</form>
<?php
$image = $_GET['image'];
$image_unicorn = "https://media.giphy.com/media/l2Jho5fnv7sfNAAZq/giphy.gif";
$image_human = "https://media.giphy.com/media/l0HlSNOxJB956qwfK/giphy.gif";
$image_cat = "https://media.giphy.com/media/3o6Zt481isNVuQI1l6/giphy.gif";
$change_image = ($image == 'unicorn') ? $image_unicorn : (($image == 'human') ? $image_human : $image_cat);
?>
<img src="<?php echo $change_image; ?>">