Show Source Code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--
The Chinese Zodiac
Amy Tavakouli
May 21, 2014
BirthYear_switch.php
-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Birth Year Fun Switch</title>

    <style>
        form
        {
            width: 400px;
            margin: 100px auto;
            margin: 1em auto;
            padding:0 2em 2em 2em ;
            border:1px solid #bbb;
            color: #333;
            background:#db7acc;
            font: 0.9em verdana, sans-serif;
        }
        FORM
        {
            width: 300px;
            margin: 100px auto;
            margin: 1em auto;
            padding:0 2em 2em 2em ;
            border:1px solid #bbb;
            color: #333;
            background:#db7acc;
            font: 0.9em verdana, sans-serif;
        }
        
        
        body
        {
            width: 400px;
            margin: 100px auto;
            margin: 1em auto;
            padding:0 2em 2em 2em ;
            border:1px solid #bbb;

            font: 0.9em verdana, sans-serif;
        }  
        
    </style>

</head>


<body>
<strong><h1 class="auto-style1" align="center"><font color="green">THE CHINESE ZODIAC</font></h1>
<h2 class="auto-style1" align="center"><font color="green">Using Switch</font></h2>
</strong>




<?php


$DisplayForm 
TRUE;
$BirthYear "";
$Counter 0;


$Rat1 = array("Start Date" => 1900"End Date" => 2020"President" => "George Washington");
$Ox1 = array("Start Date" => 1901"End Date" => 2021"President" => "Barak Obama");
$Tiger1= array("Start Date" => 1902"End Date" => 2022"President" => "Dwight Eisenhower");
$Hare1 = array("Start Date" => 1903"End Date" => 2023"President" => "John Adams");
$Dragon1 = array("Start Date" => 1904"End Date" => 2024"President" => "Abraham Lincoln");
$Snake1= array("Start Date" => 1905"End Date" => 2025"President" => "John Kennedy");
$Horse1 = array("Start Date" => 1906"End Date" => 2026"President" => "Theodore Roosevelt");
$Goat1 = array("Start Date" => 1907"End Date" => 2027"President" => "James Madison");
$Monkey1= array("Start Date" => 1908"End Date" => 2028"President" => "Harry Truman");
$Rooster1 = array("Start Date" => 1909"End Date" => 2029"President" => "Grover Cleveland");
$Dog1 = array("Start Date" => 1910"End Date" => 2030"President" => "Geore Walker Bush");
$Pig1= array("Start Date" => 1911"End Date" => 2031"President" => "Ronald Reagan");

$AnimalSigns = array("Rat" => $Rat1,
                     
"Ox" => $Ox1,
                     
"Tiger" => $Tiger1,
                     
"Rabbit" => $Hare1,
                     
"Dragon" => $Dragon1,
                     
"Snake" => $Snake1,
                     
"Horse" => $Horse1,
                     
"Goat" => $Goat1,
                     
"Monkey" => $Monkey1,
                     
"Rooster" => $Rooster1,
                     
"Dog" => $Dog1,
                     
"Pig" => $Pig1
                       
);
    

$Monkey "<td align=\"center\"><img src=\"Images/MONKEY.jpg\"></td>";
$Goat "<td align=\"center\"><img src=\"Images/GOAT.jpg\"></td>";
$Horse "<td align=\"center\"><img src=\"Images/HORSE.jpg\"></td>";
$Ox ="<td align=\"center\"><img src=\"Images/OX.jpg\"></td>";
$Boar "<td align=\"center\"><img src=\"Images/PIG.jpg\"></td>";
$Rabbit "<td align=\"center\"><img src=\"Images/HARE.jpg\"></td>";
$Rat "<td align=\"center\"><img src=\"Images/RAT.jpg\"></td>";
$Rooster "<td align=\"center\"><img src=\"Images/ROOSTER.jpg\"></td>";
$Snake "<td align=\"center\"><img src=\"Images/SNAKE.jpg\"></td>";
$Tiger "<td align=\"center\"><img src=\"Images/TIGER.jpg\"></td>";
$Dragon "<td align=\"center\"><img src=\"Images/DRAGON.jpg\"></td>";
$Dog "<td align=\"center\"><img src=\"Images/DOG.jpg\"></td>";






if (isset(
$_POST['Submit'])) {
    
$BirthYear $_POST['BirthYear'];
    if (
is_numeric($BirthYear)) {
        
$DisplayForm False;
         echo 
"<p><center>You were born in " $BirthYear".</center></p>\r\n";
                
$BirthSign $BirthYear%12;
                
$ChosenSign "";
                switch (
$BirthSign) {
                    case 
0:
                        
$ChosenSign "Monkey";
                           echo 
"<p><center>You were born under the sign of the Monkey.</center></p><br />\n";
                           echo 
"<p><center>" $Monkey "</center></p>";
                          break;
                     case 
1:
                         
$ChosenSign "Rooster";
                           echo 
"<p><center>You were born under the sign of the Rooster.</center></p><br />\n";
                           echo 
"<p><center>" $Rooster "</center></p>";             
                        break;
                    case 
2
                        
$ChosenSign "Dog";
                           echo 
"<p><center>You were born under the sign of the Dog.</center></p><br />\n";
                           echo 
"<p><center>" $Dog "</center></p>";
                           break;
                      case 
3
                          
$ChosenSign "Pig";
                           echo 
"<p'><center>You were born under the sign of the Pig.</center></p><br />\n";
                           echo 
"<p><center>" $Dog "</center></p>";
                        break;
                    case 
4:
                        
$ChosenSign "Rat";
                           echo 
"<p><center>You were born under the sign of the Rat.</center></p><br />\n";
                           echo 
"<p><center>" $Rat "</center></p>";
                        break;
                    case 
5
                        
$ChosenSign "Ox";
                           echo 
"<p><center>You were born under the sign of the Ox.</center></p><br />\n";
                           echo 
"<p><center>" $Ox "</center></p>";
                        break;
                    case 
6:
                        
$ChosenSign "Tiger";
                           echo 
"<p><center>You were born under the sign of the Tiger.</center></p><br />\n";
                           echo 
"<p><center>" $Tiger "</center></p>";
                           break;
                       case 
7:
                           
$ChosenSign "Hare";
                           echo 
"<p><center>You were born under the sign of the Hare.</center></p><br />\n";
                           echo 
"<p><center>" $Hare "</center></p>";
                        break;
                    case 
8:
                        
$ChosenSign "Dragon";
                           echo 
"<p><center>You were born under the sign of the Dragon.</center></p><br />\n";
                           echo 
"<p><center>" $Dragon "</center></p>";
                        break;
                    case 
9:
                        
$ChosenSign "Snake";
                           echo 
"<p><center>You were born under the sign of the Snake.</center></p><br />\n";
                           echo 
"<p><center>" $Snake "</center></p>";
                        break;
                    case 
10
                        
$ChosenSign "Horse";
                           echo 
"<p><center>You were born under the sign of the Horse.</center></p><br />\n";
                           echo 
"<p><center>" $Horse "</center></p>";
                        break;
                    case 
11:
                        
$ChosenSign "Goat";
                           echo 
"<p><center>You were born under the sign of the Goat.</center></p><br />\n";
                           echo 
"<p><center>" $Goat "</center></p>";
                        break;
                    default:
                        
$ChosenSign "";
                           echo 
"<p><center>You need to enter a numeric value between 1924 and 2031.</p>\n";
                        
$BirthYear "";
                        
$DisplayForm TRUE;
                        break;
                    }
                    

        
$SignMessage "<p><center>If your Chinese Zodiac sign is the $ChosenSign, you share a zodiac sign with
                        President " 
$AnimalSigns[$ChosenSign]["President"] . ".\n ";
        
$SignMessage .= "Years of the $ChosenSign include ";
        for (
$i $AnimalSigns[$ChosenSign]["Start Date"];
             
$i $AnimalSigns[$ChosenSign]["End Date"];
             
$i+=12)
                 
$SignMessage .= $i ", ";
                    
$SignMessage .= "and " $AnimalSigns[$ChosenSign]["End Date"] . ". </center></p>";
        echo 
$SignMessage;
        echo 
"<FORM><p align='center'><INPUT Type='button' VALUE='Go Back' onClick='history.go(-1);return true;'></p></FORM>\n";
     }    
    else
        {
            echo 
"<p>You need to enter a numeric value between 1924 and 2031.</p>\n";
            
$BirthYear "";

        }
    }
if (
$DisplayForm) {
?>
    
    
    
    
    
    <form name="BirthYear_switch" action="BirthYear_switch.php" method="post">
    <p>Year of Birth: <input type="text" name="BirthYear" value="<?php echo $BirthYear?>" /> </p>
    <p><input type="submit" name="Submit" value="Enter" /><br></p>
    <p><input type="reset" name="Clear" value="Clear Form" /></p>&nbsp;&nbsp;

    </form>
    <FORM><p align='center'><INPUT Type="button" VALUE="Go Back" onClick="history.go(-1);return true;"></p></FORM>
    
    
    
    
<?php
}
else
{
    
$Dir "Statistics";
    if (
is_dir($Dir)) {
        
chdir("Statistics");
        
        If (
file_exists($BirthYear.".txt"))
            
$Counter file_get_contents($BirthYear.".txt");
        else
            
$Counter 0;
        
        
$Counter = ++$Counter;
        echo 
"<p><center>You are person " $Counter " to enter the year " $BirthYear".</center></p>";
        
file_put_contents($BirthYear.".txt",$Counter);
        }
        
    else
        {
        
mkdir("Statistics");
        
chdir("Statistics");
        
$Counter 1;
        echo 
"<p><center>You are person " $Counter " to enter the year " $BirthYear".</center></p>";
        
file_put_contents($BirthYear.".txt",$Counter);
        }
    }
?>
<br>
<?php
include("include/inc_text_links.php");
?>
<br>
</body>

</html>