2014-02-07 81 views
0

將禁用的組合框和單選按鈕保存在MySQl表中,是否有任何方法可以使用PHP保存禁用的選擇選項的值和禁用的複選框的值。我已經嘗試過只讀。 Readonly在文本框中工作正常,但沒有下拉和複選框。 這裏是部分的html代碼。如何在PHP表中使用PHP

<tr> 
<td width=241>First Name : 
<input type="text" name="child_name" id="reg_no" value="<?php echo $row->eq_name;?>" readonly/></td> 
<td align="center">Middle Name : 
<input type="text" name="mid_name" id="reg_no" value="<?php echo $row->mid_name;?>" readonly/></td> 
<td width="250" colspan="2">Last Name : 
<input type="text" name="last_name" id="reg_no" value="<?php echo $row->last_name;?>"readonly /></td> 
<td></td> 
</tr> 
<tr> 
<td> Category</td> 
<td><input type="text" id="cast_cate" name="cast_cate" value="<?php echo $row->scat_id;?>" readonly/>&nbsp;&nbsp;&nbsp; 
BPL <input type="checkbox" id="bpl" name="bpl" value="<?php echo $row->e_bpl;?>" <?php if($row->e_bpl=="Yes"){?> checked<?php } ?> readonly /> 
EWS <input type="checkbox" id="ews" name="ews" value="<?php echo $row->e_ews;?>" <?php if($row->e_ews=="Yes"){?> checked<?php } ?> readonly /> 
SGC <input type="checkbox" id="sgc" name="sgc" value="<?php echo $row->e_sgc;?>" <?php if($row->e_sgc=="Yes"){?> checked<?php } ?> readonly /> 
</td> 
<td width="158"> 
Handicap<input type="checkbox" id="handi" name="handi" value="<?php echo $row->ehandi;?>" <?php if($row->ehandi=="Yes"){?> checked<?php } ?> readonly /> 
</td> 

這是PHP代碼 -

$q2="insert into es_preadmission(pre_fname,m_name,pre_lname,pre_scat_id,pre_handi,pre_ews,pre_sgc,pre_bpl) values('".ucfirst($_POST['eq_name'])."','".$_POST['mid_name']."','".ucfirst($_POST['last_name']).$_POST['cast_cate']."','".$handicap."','".$ews."','".$sgc."','".$bpl."','".$_POST['house']."')"; 
$log_insert_exe=mysql_query($q2) or die(mysql_error()); 

我歡迎任何的意見/建議

+1

請你寫** **任何更多的SQL接口的代碼之前,你必須在[正確的SQL逃逸(http://bobby-tables.com/php),以避免嚴重[讀了SQL注入漏洞](http://bobby-tables.com/)就像你在這裏。另外,'mysql_query'不應該在新的應用程序中使用。這是從PHP的未來版本中刪除的不推薦使用的界面。像[PDO這樣的現代化替代品並不難學](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/)並且一種更安全的方式來撰寫查詢。 '$ _POST'數據永遠不會直接在查詢中。 – tadman

+0

@tadman感謝您提供這些有價值的信息 – user3100533

回答

1

禁用意味着它不會被提交,我不知道,但我不認爲只讀選項和輸入[type =「checkbox」]。您可以在禁用屏幕上渲染,但您需要在隱藏輸入中推送值以提交它們。

<input type="checkbox" value="test" name="test_display" /> // will be displayed 
<input type="hidden" name="test" value="test" /> // will be posted