Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('DEFAULT_DATE', '1987-10-29', true);
- $result = '';
- $astro_signs = array (
- 'Capricorn','Aquarius', 'Pisces','Aries',
- 'Taurus','Gemini','Cancer', 'Leo',
- 'Virgo','Libra','Scorpio','Sagitarius'
- );
- if (isset($_GET['person_date']))
- {
- $my_month = (int) substr($_GET['person_date'], 5, 2);
- $my_day = substr($_GET['person_date'], 8, 2);
- $key = $my_month - 1;
- if($my_day >= 23)
- {
- $key++;
- }
- $key = $key % 12;
- $result = 'Your ast sign is '.$astro_signs[$key];
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <title>Ex2.PHP1 Forms</title>
- </head>
- <body>
- <h2>Exercise 2 - Forms</h2>
- <h1>Signs</h1>
- <?php echo $result; ?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
- <input type="text" name="person_date" value="<?php echo (isset($_GET['person_date']) && $_GET['person_date'] !='' ? $_GET['person_date']: DEFAULT_DATE ); ?>" />
- <br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement