Avatar of Souvik Misra
Souvik Misra

asked on 

Date of birth insertion insertion in mysql through php.

I am having a problem while inserting the Date of Birth field's value from html form to mysql datebase using the php. I have used the input type 'date' in html to get the input.
<?php
       $DOB=$_POST['DOB'];
      $DOB = explode("/",$DOB);
      $DOB = "$DOB[2]-$DOB[0]-$DOB[1]";
      $sql = "INSERT INTO signin (F_name,U_name,password,email,DOB,phn)VALUES ('$F_name','$U_name','$password','$email','$DOB','$phn')";
?>
<html
DOB:<input type="date" name="DOB" size="20"><br><br>
/html>

output error:
( ! ) Notice: Undefined offset: 2 in C:\wamp64\www\Blogger\signin.php on line 20
Call Stack
#      Time      Memory      Function      Location
1      0.0004      248128      {main}( )      ...\signin.php:0

( ! ) Notice: Undefined offset: 1 in C:\wamp64\www\Blogger\signin.php on line 20
Call Stack
#      Time      Memory      Function      Location
1      0.0004      248128      {main}( )      ...\signin.php:0
Error: INSERT INTO signin (F_name,U_name,password,email,DOB,phn)VALUES ('kkkk','qqqqq','77777','mmmmmmmmm','/2017-03-24/','10000000')
Incorrect date value: '/2017-03-24/' for column 'DOB' at row 1
HTMLPHP* datetimeMySQL Server

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon