在php中提交编辑表单后日期返回空值
HTML CODE IS
<form class="form-horizontal" action="" method="post" >
<label for="coupon_strt_date" >Start Date</label>
<input type="text" name="coupon_strt_date" id="datepicker" value="<?php echo $cats_rows['coupon_strt_date']; ?>" class='datepick'>
<label for="coupon_exp_date" class="control-label">Exp Date</label>
<input type="text" name="coupon_exp_date" value="<?php echo $cats_rows['coupon_exp_date']; ?>" id="datepicker" class='datepick'>
<input type="submit" name="submit" value="submit">
</form>
<?php
include("config.php");
$tbl_name = "coupons";
if (isset($_POST['submit'])){
$id=$_POST['id'];
$coupon_strt_date = $_POST['coupon_strt_date'];
$coupon_exp_date = $_POST['coupon_exp_date'];
$sql="update $tbl_name set coupon_strt_date = STR_TO_DATE('$_POST[coupon_strt_date]', '%m/%d/%Y'), coupon_exp_date = STR_TO_DATE('$_POST[coupon_exp_date]', '%m/%d/%Y') where id='$id'";
if (!mysql_query($sql))
{
echo "Error Accured";
}
else {
echo " Successfull";
}
}
虽然我正在保存数据..更改日期后日期变为空值..添加表单工作正常..但编辑表单是日期正在获取空值..请用正确的代码建议我..