<link href="../css/chinese.css" rel="stylesheet" type="text/css" />
<?php

/*
Name:    Amy Jean Charette
Date: October 11, 2009
Purpose:    Chinese Zodiac Sign process user input and display the corrent Zodiac Sign according to the users birth year.
*/

//variable that reads the animals text file into an indexed array
$text file("animals.txt");

//first part of table variable used to cut down on amount of repeated code
$table1 "<table class='animals' width='650' cellspacing='10'><tr><td><img src='../Images/";

//middle part of table variable used to cut down on amount of repeated code
$table2 ".png' /></td><td valign='top'><h1>";

//end part of table variable used to cut down on amount of repeated code
$table3 "</p></td></tr><table>\r\n";

//variable for each sign with a talbe to display the name, image, and description
$Monkey $table1 "monkey" $table2 "Monkey</h1><p>" $text[0] . $table3;
$Rooster $table1 "rooster" $table2 "Rooster</h1><p>" $text[1] . $table3;
$Dog $table1 "dog" $table2 "Dog</h1><p>" $text[2] . $table3;
$Pig $table1 "pig" $table2 "Pig</h1><p>" $text[3] . $table3;
$Rat $table1 "rat" $table2 "Rat</h1><p>" $text[4] . $table3;
$Ox $table1 "ox" $table2 "Ox</h1><p>" $text[5] . $table3;
$Tiger $table1 "tiger" $table2 "Tiger</h1><p>" $text[6] . $table3;
$Rabbit $table1 "rabbit" $table2 "Rabbit</h1><p>" $text[7] . $table3;
$Dragon $table1 "dragon" $table2 "Dragon</h1><p>" $text[8] . $table3;
$Snake $table1 "snake" $table2 "Snake</h1><p>" $text[9] . $table3;
$Horse $table1 "horse" $table2 "Horse</h1><p>" $text[10] . $table3;
$Sheep $table1 "sheep" $table2 "Sheep</h1><p>" $text[11] . $table3;


//Checks if the submit button has been pressed
if (isset($_POST['submit'])) {
    
//Checkes if you entered a birth year
    
if (!empty($_POST['birth_year'])) {
        
//Checks if the user input for birth year is numeric
        
if (is_numeric($_POST['birth_year'])) {
            
//sets the user birthyear input to teh $birthyear variable
            
$birthyear $_POST['birth_year'];
            
//tells the user what year they were born
            
echo "<p class='test3'>Your were born in " $birthyear".</p>\r\n";
            
//Checks if the entery was within the specifiec range of 1912 thur 2019
            
if ($birthyear >= 1912 && $birthyear <= 2019) {
                
$sign $birthyear%12;
                if (
$sign==0){
                echo 
"<p class='test2'>You were born under the sign of the Monkey.</p><br />\n";
                echo 
"<hr />";
                echo 
$Monkey;
                echo 
"<hr />";
                }
                    elseif (
$sign==1) {
                    echo 
"<p class='test2'>You were born under the year of the Rooster.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Rooster;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==2) {
                    echo 
"<p class='test2'>You were born under the year of the Dog.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Dog;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==3) {
                    echo 
"<p class='test2'>You were born under the year of the Pig.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Pig;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==4) {
                    echo 
"<p class='test2'>You were born under the year of the Rat.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Rat;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==5) {
                    echo 
"<p class='test2'>You were born under the year of the Ox.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Ox;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==6) {
                    echo 
"<p class='test2'>You were born under the year of the Tiger.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Tiger;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==7) {
                    echo 
"<p class='test2'>You were born under the year of the Rabbit.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Rabbit;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==8) {
                    echo 
"<p class='test2'>You were born under the year of the Dragon.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Dragon;
                    echo 
"<hr />";
                    }

                    elseif (
$sign==9) {
                    echo 
"<p class='test2'>You were born under the year of the Snake.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Snake;
                    echo 
"<hr />";
                    }                        

                    elseif (
$sign==10) {
                    echo 
"<p class='test2'>You were born under the year of the Horse.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Horse;
                    echo 
"<hr />";
                    }            

                    elseif (
$sign==11) {
                    echo 
"<p class='test2'>You were born under the year of the Sheep.</p><br />\n";
                    echo 
"<hr />";
                    echo 
$Sheep;
                    echo 
"<hr />";
                    }    

            }
            
//displays if the user entered a invalid date out of the specified range
            
else {
                echo 
"Your birthyear must be between 1912 and 2019 (year must be four digits)";
            }
        }
        
//displays if the user did not enter a year digit year
        
else {
            echo 
"You must enter a 4-digit number";
        }
    }
    
//displays if the user did not enter a year
    
else {
        echo 
"You must enter a <a href = 'zodiac_sign.html'>birthyear</a>.<br />\n";
    }
}
//displays if the user did not click on the submit button to process the form
else {
    echo 
"Please click <a href = 'zodiac_sign.html'>form</a> to enter a birthyear<br />\n";
}

?>