2014-02-07 3 views
1

MySQL 테이블에 2 개의 날짜를 보내려고합니다. 사용 나는 상단에 연도 볼 수 있습니다 위의 코드에 의해 codes-숨겨진 필드 데이터가 MySQL에 삽입되지 않습니다.

<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> 

을 다음 그러나 숨겨진 필드 데이터가이 코드

$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']."')"; 

를 사용하여 MySQL로하지 않을 것은 어디 내 실수

+1

Sidenote : POST에서 직접 삽입하는 것은 좋은 생각이 아닙니다. 그리고 우연히'mysql_ * '을 사용한다면 그것은 또 다른 실수입니다. –

+1

또한 (숨겨진) 입력을 echo 할 필요가 있습니다. 와' '비록 그들이 숨겨져 있지만, 그들은 여전히 ​​echo'ed해야합니다. 아마도 그럴 것입니다. –

답변

1
입니다

숨겨진 출력 값은 echo을 사용하지 않아도 아무런 결과가 없습니다.

이 시도 :

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

당신의 방법을 시도했지만 내 사용자 정의 오류 메시지가 비어있다. ($ _ POST [ 'from_acad']) && $ _POST [ 'to_acad']) $ {$ errormessage [33] = "빈 학년";} – user3100533

0

내가이 코드는

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

오류를 내가 왼쪽 바보 같은 실수를 보여주는 왜 내 실수 있어요! 발행 번호

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

그러나 모든 지원자에게도 감사드립니다.

관련 문제