Php 复选框数据上的未定义索引
运行下面的代码时,我得到了错误:未定义索引:数据 以下是代码的关键部分,包括工作正常的部分: 我创建了一个表单来选择日期-这一切都很好Php 复选框数据上的未定义索引,php,checkbox,undefined,Php,Checkbox,Undefined,运行下面的代码时,我得到了错误:未定义索引:数据 以下是代码的关键部分,包括工作正常的部分: 我创建了一个表单来选择日期-这一切都很好 <div class="dates"> <form method="POST" action=""> <label for="StartDate">Start Date:</span></label> <input t
<div class="dates">
<form method="POST" action="">
<label for="StartDate">Start Date:</span></label>
<input type="datetime-local" id="StartDate" name="StartDate" value="<?php
if(isset($_POST['StartDate'])){echo $_POST['StartDate'];}?>"/>
<label for="EndDate">End Date:</span></label>
<input type="datetime-local" id="EndDate" name="EndDate" value="<?php if(isset($_POST['EndDate']))
{echo $_POST['EndDate'];}?>"/>
<input type="submit">
</form>
</Body>
</HTML>
</div>
如果有人能看到我的错误,我将不胜感激。问题是:
<form method="POST">
<?php
...
<td><input type="checkbox" value='<?php echo $row['lead_id']?>' name="data[]"/></td></tr>";
</form>
这回答了你的问题吗?您首先创建的HTML无效。您不能在这样的位置将表单嵌套到表中-它必须围绕整个表,或者包含在单个表单元格中。非常感谢!!!现在一切都好了。非常感谢。
?>
<div>
<form method="post">
<input type="submit" name="Button1"
value="Send Email"/>
</form>
</head>
</div>
if(isset($_POST['data']) && !empty($_POST['data']))
foreach($_POST['data'] as $name) echo $name;
<form method="POST">
<?php
...
<td><input type="checkbox" value='<?php echo $row['lead_id']?>' name="data[]"/></td></tr>";
</form>
<div>
<form method="post">
<input type="submit" name="Button1"
value="Send Email"/>
</form>
</head>
</div>