PHP keep input type=date value after form submit


i want to keep my input type=date value after onchange form submit

Current HTML code

             <input type="date" id="Date" name="Date" placeholder="Date" value=”<?php echo $_POST['Date'];?>” onchange="this.form.submit();">

So after onchange, I want the value of the date remain same. I tried many ways but it didn’t work. Thanks for helping


Please check with this, I am seeing issue with quote as well in your HTML, so copy below code to see.

<input type="date" id="Date" name="Date" placeholder="Date" value="<?php echo isset($_REQUEST['Date'])?date("Y-m-d",strtotime($_REQUEST['Date'])):'';?>" onchange="this.form.submit();">

Answered By – PHP Hupp Technologies

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published