Hi everyone,
The following code displays a form to extract date from user and show the date within its’ div.
When the selected date is displayed, it is displayed above the form !
Why ?!
Question 1:
How do I place, via PHP, the selected date, within its’ div, beneath the form?
Question 2:
I’d like the text of the above mentioned div to be red. Can I add to .myDiv class a rule (or just change
The value) “(color: red ;)”. Can I do it whereby php code ?
Thanks a lot!
<?php
//form_date_to_php_div1.php
require_once '../myInitial.php';
require_once '../myLogin.php';
MYSQLI_SET_CHARSET($myConnection,'UTF8');
$myDate = time();
$myDate1 = date('Y-m-d l', $myDate);
if (isset($_GET['dateToDiv']))
{
$myDate1 = sanitize1($myConnection, $_GET['dateToDiv']);
echo '<p class = "myDiv">'.$myDate1.'</p>';
}
function sanitize1($conn, $aDate)
{
return htmlentities(sanitize2($conn, $aDate));
}
function sanitize2($conn, $aDate)
{
if (get_magic_quotes_gpc()) $aDate = stripslashes($aDate);
return $conn->real_escape_string($aDate);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>form_date_tp_php_div.php</title>
<style>
.myDiv
{
display:block;
width: 10%;
height: 10%;
border: 1px solid red;
}
</style>
</head>
<body>
<form action = "form_date_to_php_div1.php" method = "GET">
<input type = "date" name = "dateToDiv" />
<input type="submit" value = "Send"/>
</form>
</body>
</html>