php - Jquery datepicker mysql date format -


i know there answers in topic i'm fresh , can't manage have insered jquery ui datepicker php code when i'm sending data mysql error: incorrect date value: '' column 'date' @ row 1

<html> <head>  <script>     $(document).ready(function() {     $("#datepicker").datepicker({         dateformat: 'yy-mm-dd'         });     }) </script> </head>  </body> <form action="query_insert.php" method="post"> <input type="text" id="datepicker"> <body> 

query_insert.php:

<?php $con = mysqli_connect("127.0.0.1", "root", "user", "pass"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $sql="insert expenses (date) values ('$_post[datepicker]' ?>  

what have change make work?

you've got multiple things wrong html..

</body> <form action="query_insert.php" method="post"> <input type="text" id="datepicker"> <body> 

should

<body> <form action="query_insert.php" method="post"> <input type="text" id="datepicker" name="datepicker"> <input type="submit" value="insert date"> </form> </body> 

basically, have add name attribute input field included in _post , _get requests, should close form (but wont stop being posted)

also, body tags wrong way around.

in query_insert.php file need finish insert statement:

$sql="insert expenses (date) values ('$_post[datepicker]' 

should be

$sql="insert expenses (date) values ('" . $_post['datepicker'] . "')"; 

warning: make sure validate $_post['datepicker'] before inserting though


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -