I need to generate an error message when an invalid date is chosen from select lists. I have set up arrays for the $days,$years,$months but I can’t get my head wrapped around how to set up the error message. For example, a leap year could not be 2/30/2012. This is in 4 files. I am only including the file for the form and the validation. I have commented out one thing I tried, and deleted the code to access the other two files. I feel like I should combine $days,$years,$months into one multidimensional array and I’ve tried but my lack of knowledge keeps me from pulling it all together with the error codes either way. Any help is much appreciated.
1st File:
<![php]<?php
//------setup for year array -----
$years = array(“1953”,“1954”,“1955”,“1956”,“1957”,“1958”,“1959”,
“1960”,“1961”,“1962”,“1963”,“1964”,“1965”,“1966”,“1967”,“1968”,“1969”,
“1970”,“1971”,“1972”,“1973”,“1974”,“1975”,“1976”,“1977”,“1978”,“1979”,
“1980”,“1981”,“1982”,“1983”,“1984”,“1985”,“1986”,“1987”,“1988”,“1989”,
“1980”,“1991”,“1992”,“1993”,“1994”,“1995”,“1996”,“1997”,“1998”,“1999”,
“2000”,“2001”,“2002”,“2003”,“2004”,“2005”,“2006”,“2008”,“2009”,“2010”,
“2011”,“2012”,“2013”);
//-----set up for days array-----
$days = array(“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”,“31”);
//-------set up for month array-------
$months = array(“January”,“February”,“March”,“April”,“May”,“June”,
“July”,“August”,“September”,“October”,“November”,“December”);
?>[/php]
//
Assignment 7_1
Enter your date of birth and I will tell you your zodiac sign!
Select Year | [php]<?php for($i=0; $i <?php echo $years[$i] ?> <?php } ?>[/php] |
Select Month | [php]<?php for($i=0; $i <?php echo $months [$i] ?> <?php } ?> |
Select Day of Month | <?php for($i=0; $i <?php echo $days [$i] ?> <?php } ?>[/php] |
2ndFile:
Web 220 Assignment7_2.php//-----setup for variables-----
$years= array(“1953”,“1954”,“1955”,“1956”,“1957”,“1958”,“1959”,
“1960”,“1961”,“1962”,“1963”,“1964”,“1965”,“1966”,“1967”,“1968”,“1969”,
“1970”,“1971”,“1972”,“1973”,“1974”,“1975”,“1976”,“1977”,“1978”,“1979”,
“1980”,“1981”,“1982”,“1983”,“1984”,“1985”,“1986”,“1987”,“1988”,“1989”,
“1980”,“1991”,“1992”,“1993”,“1994”,“1995”,“1996”,“1997”,“1998”,“1999”,
“2000”,“2001”,“2002”,“2003”,“2004”,“2005”,“2006”,“2008”,“2009”,“2010”,
“2011”,“2012”,“2013 !? ! ? Dorian Grey is just a myth quit screwing around”);
$months=array(“January”,“February”,“March”,“April”,“May”,“June”,
“July”,“August”,“September”,“October”,“November”,“December”);
$days=array (“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”,“31”);
$zodiac= array(“month0”,“month01”,“month02”,“month03”,“month04”,“month05”,“month06”,“month07”,
“month08”,“month09”,“month10”,“month11”);
$images= “months$zodiac.png”;//(“month0.jpg,”“month01.jpg,”“month02.jpg,”“month03.jpg,”“month04.jpg,”“month05.jpg,”
//“month06.jpg,”“month07.jpg,”“month08.jpg,”“month09.jpg,”“month10.jpg,”“month11.jpg,”);
//$zodiac=array(‘years’=>$years, ‘months’=>$months, ‘days’=>$days);
$dayName=$days[$firstday];
$moName=$months[$firstmonth];
$yrName=$years[$firstyear];
$Date= $firstday+$firstmonth+$firstyear;
$invalidDate = array(‘2 29 1956’,‘2 29 1960’,‘2 29 1964’,‘2 29 1968’,‘2 29 1972’,‘2 29 1976’,
‘2 29 1980’,‘2 29 1984’,‘2 29 1988’,‘2 29 1984’,‘2 29 1988’,‘2 29 1992’,‘2 29 1996’,‘2 29 2000’,
‘2 29 2004’,‘2 29 2008’,‘2 29 2012’,‘2 30 years’,‘2 31 years’, ‘9 31 years’,‘4 31 years’,‘6 31 years’,‘11 31 years’);
//-----error message management-----
//$error=’’;
//$i=1;
//$errorMsg=’’;
//foreach ($invalidDate as $value )
//$Date= false;
//
//if ($invalidDate==true)
// {
// $errorMsg = “Invalid Date!”;
// $Date= false;
// }
// else
// {
// $errorMsg= “
You entered the following date !
”;//}
?>[/php]
<?php echo $dayName?> <?php echo $moName?> <?php echo $yrName?>[/php]
Your Zodiac Sign is:
[php]