Copy form input

I have a form input which is a date input. If someone selects a date from the form input i want this date to be repeated again.further down the page.

my code for form input is

<label for="date">Date Of Agreement.</label>
<input type="date" name="date" value="<?php if (isset($_POST['date'])) { echo htmlspecialchars($_POST['date']); } ?>">

The form is sent to my email but i want to copy the date submitted in the form input further down the page to confirm.

so for example if a user inputs 30/12/2022 from the date picker then further down the form (same page) i want to display something like:

This agreement was made on 30th December 2022

using php coding for the page.

thanks

sorry my input not shown correctly.

Date Of Agreement.

<label for="date">Date Of Agreement.</label>
<input type="date" name="date" value="<?php if (isset($_POST['date'])) { echo htmlspecialchars($_POST['date']); } ?>">

If you want to display the value somewhere else on the page before the form has been submitted, you will need to use javascript. If you want to display the the value after the form has been submitted, you would store it in a session variable, as part of a success message, then test and display the contents of that session variable at the appropriate location in the html document.

If neither of these sounds like what you are asking about, you need to provide much more detail about the who, what, when, where, and why of what you want so that someone can help with the how to do it information.

As mentioned… if this is for an email AFTER submission … then you can just use the $_POST value anywhere you want to display it.

Sponsor our Newsletter | Privacy Policy | Terms of Service