Obtain Date value from HTML form and pass it in PHP
Solution:
Change
to
{-code-2}
The default HTTP method of a form is {-code-3}
. You must specify {-code-4}
since you are accessing it using $_{-code-4}
. Then you should be able to get the value of the {-code-6}
field in ${-code-6}
.
If it doesn't fix the errors, try the following:
1 Check the datatype of {-code-6}
column in your MySQL table, and make sure that your ${-code-6}
is in correct format.
For example: If your {-code-6}
column is a {-code-11}
column, ${-code-6}
should be in {-code-13}
format.
Other Date - Time types and format is given here:
Date and Time Types DescriptionAnswer
Answer
Answer
Answer
Answer
Answer
-----
{-code-11} A date value in CCYY-MM-DD formatAnswer
Answer
Answer
Answer
Answer
Answer
-----
TIME A time value in hh:mm:ss formatAnswer
Answer
Answer
Answer
Answer
Answer
-----
{-code-11}TIME A date and time value inCCYY-MM-DD hh:mm:ss formatAnswer
Answer
Answer
Answer
Answer
Answer
-----
TIMESTAMP A timestamp value in CCYY-MM-DD hh:mm:ss formatAnswer
Answer
Answer
Answer
Answer
Answer
-----
YEAR A year value in CCYY or YY formatAnswer
Answer
Answer
Answer
Answer
Answer
-----
Extra Read: Methods GET and POST in HTML forms - what's the difference?http://jkorpela.fi/forms/methods.html
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Solution:
In the database you need to set the date field to type date and in the input field of the form you need to capture the correct date format. Or alternatively use a date picker field
<label><strong>Date </strong> </label></div>
<input type="date" name="date">
Answer
Solution:
If you need the current date just you the built-in date in php
$now = date('Y-m-d');
Else check your sql date column and make sure it's Varchar then do this
<form action="insert.php"
method="post">
//in your insert try using
'".$Data."' in place of '$Data'
Source