Please fellows help me out! I have this departure date selection form and eg. today is 17 and i select 20. If i didn't fill in any required field before pressing send, the form will refer back to the form and all the other fields stays remembered but the departure field reselt to todays date. Please could anyone help so that it stays remembered like the other fields? That would be great! Hier are the codes:

<?
Function ShowFromDate($year_interval,$YearIntervalType) {
//GLOBAL $day,$month,$year;

//DAY
echo "<select class='formDay' name='AbreisedatumD'>\n";
$i=1;
$date = strtotime("+1 day");
$CurrDay=date("d", $date);
If(!IsSet($day)) $day=$CurrDay;
while ($i <= 31)
      {
       If(IsSet($day)) {
         If($day == $i || ($i == substr($day,1,1) && (substr($day,0,1) == 0))) {
                  echo"<option selected> $day\n";
                  $i++;
         }Else{
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo "<option> $i\n";
                }
                $i++;
         }
       }Else {
              If($i == $CurrDay)
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo"<option> $i\n";
                }
              Else {
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo "<option> $i\n";
                }
              }
              $i++;
       }
      }
echo "</select>\n";

//MONTH
echo "<select class='formMonth' name='AbreisedatumM'>\n";
$i=1;
$CurrMonth=date("m");
while ($i <= 12)
     {
      If(IsSet($month)) {
         If($month == $i || ($i == substr($month,1,1) && (substr($month,0,1) == 0))) {
            echo"<option selected> $month\n";
            $i++;
         }Else{
            If($i<10) {
               echo "<option> 0$i\n";
            }Else {
               echo "<option> $i\n";
            }
            $i++;
         }
      }Else {
            If($i == $CurrMonth) {
              If($i<10) {
                 echo "<option selected> 0$i\n";
              }Else {
                 echo "<option selected> $i\n";
              }
            }Else {
              If($i<10){
                 echo "<option> 0$i\n";
              }Else {
                 echo "<option> $i\n";
              }
            }
            $i++;
      }
}
  echo "</select>\n";

//YEAR
  echo "<select class='formYear' name='AbreisedatumY'>\n";
  $CurrYear=date("Y");
  If($YearIntervalType == "Past") {
      $i=$CurrYear-$year_interval+1;
      while ($i <= $CurrYear)
           {
            If($i == $year) {
               echo "<option selected> $i\n";
            }ElseIf ($i == $CurrYear && !IsSet($year)) {
               echo "<option selected> $i\n";
            }Else {
               echo "<option> $i\n";
            }
            $i++;
           }
       echo "</select>\n";
  }
  If($YearIntervalType == "Future") {
      $i=$CurrYear+$year_interval;
      while ($CurrYear < $i)
           {
            if ($year == $CurrYear) echo "<option selected> $CurrYear\n";
              else echo "<option> $CurrYear\n";
            $CurrYear++;
           }
       echo "</select>\n";
  }
  If($YearIntervalType == "Both") {
      $i=$CurrYear-$year_interval+1;
      while ($i < $CurrYear+$year_interval)
           {
            if ($i == $CurrYear) echo "<option selected> $i\n";
              else echo "<option> $i\n";
            $i++;
           }
       echo "</select>\n";
  }
}

//Ussage Example :
ShowFromDate(4,"Future");
?>

Best regard

When the user posts re-assign the $Curr variables to whatever value they posted.

$CurrDay = $_POST['day'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.