Jump to content

Value selected date.


r00ttap

Recommended Posts

Maybe I've been starring at code too long but is there any reason why this wouldn't work?

 

I have a menu for the Year, Month, and Day and none seem to be working but I'll post the year as an example.

 

<select name="year">
<option selected value="<?php echo date(Y); ?>"><?php echo date(Y); ?></option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select>

 

It works as much as the current year being displayed by default but if I submit the form without touching the drop down menu it won't send the year to the database but if I manually select the year it will work.

 

What am I missing?

Link to comment
https://forums.phpfreaks.com/topic/148298-value-selected-date/
Share on other sites

Must be the way you're using POST.  We would need to see the processing part.  I used this code and it outputs "2009" to the browser when I don't select anything...

 

if(isset($_POST['submit'])) {
  echo $_POST['year'];
}
?>
</pre>
<form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="POST">
;
;
2009;
2010;


<

 

Oh, and why do you have date(Y) and 2009?

Link to comment
https://forums.phpfreaks.com/topic/148298-value-selected-date/#findComment-778653
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.