2014-02-07 32 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