【发布时间】:2017-09-25 14:58:04
【问题描述】:
我有一个模态表单。当我按下提交按钮时,php 文件运行时出现以下错误: 注意:未定义索引:第 2 行 C:\xampp\htdocs\site\bank.php 中的 phone1 注意:未定义索引:第 4 行 C:\xampp\htdocs\site\bank.php 中的charge1
这是bank.php中的PHP代码:
<?php
echo $_POST["phone"];
echo "</br>";
echo $_POST["charge"];
?>
这里是模态内容:
<!-- Modal content-->
<div class="modal fade" id="register" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal title here</h4>
</div>
<div class="modal-body">
<form id="modal-form" class="form-horizontal" method="POST" action="bank.php">
<div class="form-group col-md-12">
<div class="form-group">
<div class="col-xs-6" style="float:right;">
<label>phone numer:</label>
<input id="phone" type="text" class="form-control" name="phone" value="pre filled value" disabled/>
<span id='display'></span>
</div>
<div class="col-xs-6" style="float:left;">
<label>charge:</label>
<input style="font-size:17px; font-weight:bold;" id="charge" type="text" class="form-control" name="charge" value="some other prefilled value" disabled/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<button class="btn btn-danger btn-default pull-right" data- dismiss="modal" style="margin-left:10px;">close</button>
<button type="submit" class="btn btn-success"> submit </button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
modal footer
</div>
</div>
</div>
</div>
如果有人帮我找出问题所在,我将不胜感激
【问题讨论】:
-
您的表单有
phone1,而您的回显是$_POST["phone"],哪个是正确的? -
好吧,名字是phone1而不是phone....而charge1不是charge....发送的是名字,而不是ids....
-
您使用数字(phone1,charge1)命名参数,但您的 php 代码在没有数字的情况下回显它们(
$_POST['change']) -
表单发布名称属性,而不是 id。因此,无论您在 name 属性中添加什么,都将显示在 PHP 端。
-
表单本身不会发送禁用的参数。您的问题的可能答案here
标签: javascript php jquery html twitter-bootstrap