0

这是我的phpcode:

error_reporting(0);
$userLog = $_SESSION['user'];

mysql_select_db("dbwebsite") or die($connect_error);

$time = time();
$event = $_POST['eventname'];
$date = $_POST['datepicker'];

if($event == "" | $date = ""){
        echo '<script type="text/javascript">alert("Type your Post First!");</script>';
        header("Refresh:-0.0001;user_admin.php");
}
else{
            $insert_error = "Your text could not be posted";
            $insert = mysql_query("INSERT INTO events VALUES ('','$event','$date','$time')") or die ($insert_error);
            header("Location:user_admin.php");
}
?>

这是我的日期选择器代码:

<script src="effects/calendar/jquery-1.9.1.js"></script>
<script src="effects/calendar/jquery-ui.js"></script>

<html>
<form action="update_event.php" name="event" id="event" method="post">
  <p style="color:#000000">Event name:<input type="text" name="eventname" id="eventname" /></p>
  <p style="color:#000000">Event Date:<input type="text" name="datepicker" id="datepicker" /></p>
  <br /><input type="submit" name="btnevent" id="btnevent" value="Post event" />
  </form>
</html>

0000-00-00 显示在我的数据库中,而不是我使用日期选择器选择的日期。

4

2 回答 2

0

$data = ""您正在为 null赋值

更改 if($event == "" | $date = ""){if($event == "" || $date == ""){

或者你可以尝试类似 isset

if(!isset($event) || !isset($date))
于 2013-10-05T04:24:31.760 回答
0
first check the datepicker posted date and change the date format
mysql date format is YYYY-MM-DD
So you change your date format

<?php
$event = $_POST['eventname'];
$date = $_POST['datepicker'];
$dd=date_create($date);
$datepic=date_format($dd,"Y-m-d");

$insert = mysql_query("INSERT INTO events VALUES ('','$event','$datepic','$time')") or die 

?>
于 2013-10-05T04:36:00.427 回答