W.Kurek W.Kurek - 1 year ago 78
PHP Question

How to insert date to MySQL from html input?

I've problem with inserting a date

enter code here
into a MySQL database. On my webpage i've got a input which type is 'date' but there is a problem with inserting value of this input into database properly.

$connection->query("INSERT INTO users VALUES(NULL, '$nick', '$password_hash', '$email',".$_POST['gender'].",".$_POST['bday'].")")

Have you got any solution for my problem?

Answer Source

Use this code. you forget Single quote (').

$connection->query("INSERT INTO users VALUES(NULL, '$nick', '$password_hash', '$email','".$_POST['gender']."','".$_POST['bday']."')")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download