Date and time can be inserted into mysql table in specific format only. But php will support different types of date and time formats.
So, we should convert the date and time from php into specific format before inserting the value into mysql table.
We can use the date() and strtotime() functions of the php to do it.
MySQL table will store and datetime correctly only when it is formatted as Y-m-d H:i:s.
(i-e) 4 digit year-2 digit month – 2 digit day blankspace 24hours hour:minute:seconds.
Refer the below sample code used for inserting datetime into mysql table.
- Assume that Date and time values are stored in two different variables($dateinput,$timeinput) in php.
- First we need to concatenate both date and time to get single string.
- Then use strtotime() to convert this single string into time data which can be formatted using date() function to get required format.Read more
Most of the websites will require the users to register them for getting username/password which can be used for logging into their website.
It is very common that the users forget their password. So, the websites should allow the users to receive their password into their email using forgot password link available in the login page.
Find below the sample php code which can be used for implementing the forgot password feature.
if ($email_to == “”) // Email address cannot be empty
header(“Location: mail-password.php?send=Email not entered”);