First of all, I think you should follow the above recommendations about using a library like Symfony Mailer, PHPMailer or better using a service as Sendgrid or Resend.
Regarding your concern, may I ask which version of PHP you're using? Since PHP 7.2, the mail() function accepts headers as an array—before that, it only accepted strings.
Looking at example #5 in the documentation, you can see that they convert the array of headers into a string using the implode() function.
Something like this:
$headers = array( 'MIME-Version' => '1.0', 'Content-type' => 'text/html;charset=UTF-8', 'From' => '[email protected]', 'Reply-To' => '[email protected]' );
$sent = mail($to, $subject, $message, implode("\r\n", $headers));
First of all, I think you should follow the above recommendations about using prepared statements. It's very risky and bad practice to use plain values directly in a query.
Regarding your concern, is there a specific reason for using 0000-00-00 00:00:00? This is an invalid date, and if you're using MySQL, the database might reject this value.
I suggest setting the otp_expiry value to NULL—I think it's better for validation. Just make sure the database table schema allows null values.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.