duanke3985
duanke3985
2014-04-29 23:08

使用datepicker选择的日期输入不会插入到我的数据库中

  • php
  • mysql
  • datepicker
  • sql

Im doing an insert with PDO that it seems correct for me, and the insert is working.

But the date_begin and date_end info is not inserting, my table receivs in this fields the value of :"0000-00-00 00:00:00.000000".

Im using datepicker to choose date.

Do you see what Can be wrong? I dont receive any error or notice!

My insert with pdo:

$insertEvent = $pdo->prepare("INSERT INTO events (title, level, date_begin, date_end) VALUES (:title, :level, :date_begin, :date_end)");  
$insertEvent->bindValue(':title', $f['tile']);
$insertEvent->bindValue(':level', $f['level']);
$insertEvent->bindValue(':date_begin', $f['date_begin']);
$insertEvent->bindValue(':date_end', $f['date_end']);
$insertEvent->execute();          
   echo'Sucess';

If I print this variables, they have the right data that I choose in date picker:

echo $f['date_begin'];
echo $f['date_end'];

My form:

<form action="" method="post" enctype="multipart/form-data">


        <label>
            <span>Title:</span>
            <input type="text"  name="title" value="<?php if(isset($_POST['title'])) echo $f['title']; ?>" />
        </label>

        <label>
            <span class="data">Begin Date:</span>
            <input type="text" class="datepicker" name="date_begin" value="<?php if(isset($_POST['date_begin'])) echo $f['date_begin']; ?>" />
        </label>

        <label>
            <span>End Date:</span>
            <input type="text" class="datepicker" name="date_end" value="<?php if(isset($_POST['date_end'])) echo $f['date_end']; ?>" />
        </label>

         <label>
           <span>Select the level:</span>
            <select name="level">
            <option value="">Select the user level;</option>
            <option value="1">1</option>
            <option value="2">2</option>        
            </select>
        </label>

        <input type="submit" value="Insert" name="sendForm" />

    </form>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐