隐藏字段数据未插入Mysql

时间:2014-02-07 21:47:39

标签: php mysql

我正在尝试在MySQL表中发送2个日期。使用以下代码 -

<table width="1050px"style="border:thin #00F solid"><tr><td>
<?php
$academic_info = getarrayassoc("SELECT * FROM `es_finance_master` ORDER BY `es_finance_masterid` DESC LIMIT 0,1");
$dfrom_acad = strtotime($academic_info['fi_ac_startdate']);
$dto_acad   = strtotime($academic_info['fi_ac_enddate']);
?>
<form  name="form" id="form" action="" method="post" enctype="multipart/form-data">
<table width="1029" cellpadding="2px" cellspacing="0" >
<tr>
<td height="25" colspan="5" class="bgcolor_02">Registration Form <span style="margin-left:500px;">Registration for <?php echo date('Y',$dfrom_acad). " - " . date('Y',$dto_acad) ?> Academic Year</span>
<input type="hidden" name="from_acad" value="<?php $academic_info['fi_ac_startdate']; ?>">
<input type="hidden" name="to_acad" value="<?php $academic_info['fi_ac_enddate']; ?>">
</td>
</tr>
<tr>
<td>Reg. No. :</td>
<td width="330" ><input type="text" name="reg_no" id="reg_no" value="<?php if(isset($_POST['reg_no'])){echo $_POST['reg_no'];} ?>" onblur="reg_check()" />      <div id="reg_err"></div>
</td>
</tr>
</form>
</table>

通过上面的代码我可以看到岁月:但隐藏的字段数据不会通过使用此代码进入MySQL

$q2="insert into es_enquiry(eq_from_aca,eq_to_aca,eq_regno) values('".date("Y-m-d",strtotime($_POST['from_acad']))."','".date("Y-m-d",strtotime($_POST['to_acad']))."','".$_POST['reg_no']."')";

我的错误在哪里

2 个答案:

答案 0 :(得分:1)

隐藏输出的值不是因为您没有使用echo

试试这个:

value="<?php echo $academic_info['fi_ac_startdate']; ?>"
value="<?php echo $academic_info['fi_ac_enddate']; ?>"

答案 1 :(得分:0)

我弄错了为什么这段代码

if(isset($_POST['from_acad']) && $_POST['to_acad']) 
{ $errormessage[33] = "Blank Academic Year";}

显示错误是我离开的一个愚蠢的错误!在isset

if(!isset($_POST['from_acad']) && $_POST['to_acad'])
{ $errormessage[33] = "Blank Academic Year";} 

但我也要感谢所有评论员的支持。