Code: Select all
if (empty($_POST['month']) || empty($_POST['day']) || empty($_POST['year']))
{
$sd = false;
$message .= 'You forgot to enter the project start date<br>';
}
else
{
$sd = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
}
//check for poject duration end date
if (empty($_POST['month']) || empty($_POST['day']) || empty($_POST['year']))
{
$ed = false;
$message .= 'You forgot to enter the project end date<br>';
}
else
{
$ed = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
}
if ($sd && $ed)
{
$query = "INSERT INTO table(startdate, enddate)
VALUES('$sd','$ed');
$result = @mysql_query($query);
if ($result)
{
echo 'project written to database';
echo '<meta http-equiv="refresh" content="3;url=http://localhost/mysample/project.php">';
exit();
}
else
{
echo 'no data was written to the database';
}
mysql_close();
}
else
{
$message .= 'Please try again';
}//end connection to dbCode: Select all
<table width="e;100%"e; cellpadding="e;1"e; cellspacing="e;1"e;>
<tr>
<td width="e;20%"e;><b/>Start Date</td>
<td width="e;80%"e;><? calendar1(); ?></td>
</tr>
<tr>
<td width="e;20%"e;><b/>End Date</td>
<td width="e;80%"e;><? calendar2(); ?></td>
</tr>
</table>calendar1() and calendar2()
which has an identical code below
Code: Select all
function calendar1()
{
//months array
$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
//dropdown
echo '<select name="month">';
echo "<option value=\"\">Month</option><br>";
foreach ($months as $key => $value)
{
echo "<option value=\"$key\">$value</option>\n";
}
echo '</select>
<select name="day">';
echo "<option value=\"\">Day</option><br>";
for ($day = 1; $day <= 31; $day++)
{
echo "<option value=\"$day\">$day</option>\n";
}
echo '</select>
<select name="year">';
echo "<option value=\"\">Year</option><br>";
$year = 2005;
while ($year <= 2010)
{
echo "<option value=\"$year\">$year</option>\n";
$year++;
}
echo '</select>';
}please help..thanks in advance..