Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.     define('DEFAULT_DATE', '1987-10-29', true);
  3.  
  4.     $result = '';
  5.  
  6.     $astro_signs = array (
  7.             'Capricorn','Aquarius', 'Pisces','Aries',
  8.             'Taurus','Gemini','Cancer', 'Leo',
  9.             'Virgo','Libra','Scorpio','Sagitarius'
  10.         );
  11.  
  12.     if (isset($_GET['person_date']))
  13.     {
  14.         $my_month = (int) substr($_GET['person_date'], 5, 2);
  15.         $my_day = substr($_GET['person_date'], 8, 2);
  16.        
  17.         $key = $my_month - 1;
  18.         if($my_day >= 23)
  19.         {
  20.             $key++;
  21.         }
  22.  
  23.         $key = $key % 12;
  24.  
  25.         $result = 'Your ast sign is '.$astro_signs[$key];
  26.     }
  27.  
  28.    
  29. ?>
  30.  
  31.  
  32. <!DOCTYPE html>
  33. <html lang="en">
  34. <head>
  35.     <meta charset="UTF-8" />
  36.     <title>Ex2.PHP1 Forms</title>
  37. </head>
  38. <body>
  39.     <h2>Exercise 2 - Forms</h2>
  40.     <h1>Signs</h1>
  41.  
  42.     <?php echo $result; ?>
  43.    
  44.     <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
  45.        
  46.         <input type="text" name="person_date" value="<?php echo (isset($_GET['person_date']) && $_GET['person_date'] !='' ? $_GET['person_date']: DEFAULT_DATE );  ?>" />
  47.         <br />
  48.         <input type="submit" name="submit" value="Submit" />
  49.          
  50.     </form>
  51.  
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement