Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.