用户提交表单时未显示日期

时间:2014-04-15 14:47:00

标签: php

所以我有一个用户填写的表单,它会添加到数据库中。除了约会,一切都有效。日期显示为0000-00-00。目前,我使用了一个日期选择器,但即使用户必须输入日期,日期也不会出现......所以这不应该是问题。

<form name="Add" id="Add" method="post" action="programadd.php">
  <p>Program Name: 
    <input name="program" type="text" id="program" />
</p>
  <p>Air Date 
    <input name="airdate" type="text" id="airdate" />
</p>
  <p>Description 
    <input name="description" type="text" id="description" s />
</p>
<p>Production
    <input name="production" type="text" id="production" />
</p>
<p>Promotions
    <input name="promotion" type="text" id="promotion"  />
</p>
<p>Community
    <input name="community" type="text" id="community" />
</p>
<p>Web
    <input name="web" type="text" id="web"  />
</p>
  <p>
    <input type="submit" name="Submit" value="Submit" />

以下是将其添加到数据库的代码:

<?php require_once('connect-db.php');
$program = $_POST['program'];
$airdate = $_POST['airdate'];
$description =  $_POST['description'];
$production = $_POST['production'];
$promotion = $_POST['promotion'];
$community = $_POST['community'];
$web = $_POST['web'];


if (mysql_query ("INSERT INTO calendar(program, airdate, description, production, community, promotion, web) VALUES 
    ('$program', '$airdate', '$description','$production', '$promotion', '$community', '$web')"))
{ echo "Program successfully added to the database <br />"; 
 }
else {
    die(mysql_error());
}
    require_once("db_connx_close.php");
?>

另一个问题是,如何将日期显示为月/日/年,而不是相反?

1 个答案:

答案 0 :(得分:0)

$date = date('Y-m-d', strtotime($_POST['airdate']));