我有一个模式,可以很好地将数据添加到数据库中。但是,我希望输入字段之一是用户可以从选择列表中进行选择的字段。我已经获得了显示带有选项的下拉列表的模态,但是当我提交时,出现索引错误,并且它没有将所选的选项发布到数据库中。这是工作脚本
`<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<form action="" enctype="multipart/form-data" name="myForm" method="post">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Beer</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-md-3 control-label">Beer Name</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" id="name" name="name" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Description</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<textarea name="description" id="description"></textarea>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer IBUs</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="ibu" id="ibu" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Abv</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="abv" id="abv" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Packaged</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="packaged" id="packaged" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">sells?</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="sells" id="sells" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Availability</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="availability" id="availability" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Category</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="category" id="category" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Tier</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="tier" id="tier" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Price One</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="pricing_1" id="pricing_1" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Price Two</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="pricing_2" id="pricing_2" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Price Three</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="pricing_3" id="pricing_3" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Heading</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input type="text" name="heading" id="heading" class="form-control" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Beer Image</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<input name="label_image" id="label_image" type="file" />
</div>
</div>
</div>
`
现在,如果我将以下代码更改为“标题”表单组,则在此行上的php文件中收到未定义的索引错误:$ headingi = mysqli_real_escape_string($ db_conx,$ _POST ['heading']);
这是我更改的代码
<div class="form-group">
<label class="col-md-3 control-label">Heading</label>
<div class="col-md-6">
<div class="input-group input-group-icon">
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
</div>
</div>
我确定这与未定义inout有关...但是我似乎无法弄清楚。