1. I would like to get my date of birth (day:, month:, year

drop down to retain selected values after submit button has been clicked and validation for something else on the same form has failed so user won't need to choose date of birth again.
2. I would also like to create a validation script for it using php not javascript.
This is how I got my gender drop down to retain selected values after signup button was clicked and something else on my form failed validation
HTML Code:
<tr>
<td>I am</td>
<td>
<select name="sex" class="select" id="sex" >
<option value="0" <?php if (isset($_POST['sex']) && $_POST['sex'] == 0) {
echo 'selected="selected"';} ?> >-Gender-</option>
<option value="1" <?php if (isset($_POST['sex']) && $_POST['sex'] == 1) {
echo 'selected="selected"';} ?>>Male</option>
<option value="2" <?php if (isset($_POST['sex']) && $_POST['sex'] == 2) {
echo 'selected="selected"';} ?>>Female</option>
</select>
</td></tr>
I would like to do the same with my birthday selection drop down and here is the code on my homepage:
HTML Code:
<tr>
<td>Birthday</td>
<td>
<?php
require_once('includes/bdayselect/bdayselect.php');
$myCalendar = new tc_calendar("dob", true);
// $myCalendar->setIcon("http://www.webmaster-talk.com/images/iconCalendar.gif");
$myCalendar->setDate(01, 03, 1900);
$myCalendar->setPath("./");
$myCalendar->setYearInterval(1900, 2010);
$myCalendar->dateAllow('1900-01-01', '2010-12-31');
//$myCalendar->setHeight(350);
//$myCalendar->autoSubmit(true, "form1");
$myCalendar->writeScript();
?>
</td>
and here is the code on my birthday script page:
HTML Code:
//write the select box of days
function writeDay(){
echo("<select name=\"".$this->objname."_day\" id=\"".$this->objname."_day\" onChange=\"javascript:tc_setDay('".$this->objname."', this[this.selectedIndex].value, '$this->path');\" class=\"tcday\">");
echo("<option value=\"00\">Day:</option>");
for($i=1; $i<=31; $i++){
$selected = ((int)$this->day == $i) ? " selected" : "";
echo("<option value=\"".str_pad($i, 2 , "0", STR_PAD_LEFT)."\"$selected>$i</option>");
}
echo("</select> ");
}
//write the select box of months
function writeMonth(){
echo("<select name=\"".$this->objname."_month\" id=\"".$this->objname."_month\" onChange=\"javascript:tc_setMonth('".$this->objname."', this[this.selectedIndex].value, '$this->path');\" class=\"tcmonth\">");
echo("<option value=\"00\">Month:</option>");
$monthnames = $this->getMonthNames();
for($i=1; $i<=sizeof($monthnames); $i++){
$selected = ((int)$this->month == $i) ? " selected" : "";
echo("<option value=\"".str_pad($i, 2, "0", STR_PAD_LEFT)."\"$selected>".$monthnames[$i-1]."</option>");
}
echo("</select> ");
}
//write the year textbox
function writeYear(){
//echo("<input type=\"textbox\" name=\"".$this->objname."_year\" id=\"".$this->objname."_year\" value=\"$this->year\" maxlength=4 size=5 onBlur=\"javascript:tc_setYear('".$this->objname."', this.value, '$this->path');\" onKeyPress=\"javascript:if(yearEnter(event)){ tc_setYear('".$this->objname."', this.value, '$this->path'); return false; }\"> ");
echo("<select name=\"".$this->objname."_year\" id=\"".$this->objname."_year\" onChange=\"javascript:tc_setYear('".$this->objname."', this[this.selectedIndex].value, '$this->path');\" class=\"tcyear\">");
echo("<option value=\"0000\">Year:</option>");
I would appreciate all help given..
This is something i've been trying to get my head around for ages..
Done multiple forum searches..
So far i'm happy because a few weeks ago I didn't think i would be able to code using php. Now i've just about finished a registration section of my website.
Thanks in advance.