我想制作简单的注册系统。用户选择要注册的事件,设置要注册的人数,然后单击“提交”。接下来,他被重定向到注册页面,系统生成注册表单并修改查询,以便将记录添加到专用于事件的表中。
我在提交复选框值方面遇到问题,我一直记得未定义索引错误。
请提出一些建议
这是代码:(HTML)
<form action="register-form.php" method="post">
<table class="table table-bordered table-hover">
<tbody>
<?php show_active_events(); ?>
</tbody>
</table>
<div class="form-group col-md-12" id="counter">
<label for="select">Wybierz ilość osób do rejestracji</label>
<select class="form-control" name="person_number">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
</div>
<button type="submit" class="btn btn-lg btn-primary col-md-12 pull-right" id="event-table-btn" name="submit">Dalej <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></button>
</div>
</form>
SHOW_ACTIVE_EVENTS FUNCTION
function show_active_events() {
global $conn;
$query = "SELECT * FROM events WHERE status NOT LIKE '0' ";
$showEvents = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($showEvents)) { ?>
<tr>
<td width="90%">
<?php
echo $row['name'];
echo "<br />";
echo $row['date'];
echo "<br />";
echo $row['time'];
echo "<br />";
?>
<div class="accordion">Szczegóły ...
<div class="accordion-content hide">
<p><?php echo $row['comment']; ?></p>
</div>
</div>
</td>
<td width="10%">
<div class="ck-button">
<label>
<input type="checkbox" class="ck" name="event" id="event" value="<?php echo $row['name'];?>"><span>Wybierz</span>
</label>
</div>
</td>
</tr>
<?php }}?>
寄存器form.php的
<?php
if (isset($_POST['submit'])) {
$persons = $_POST['person_number'];
$event = $_POST['event'];
echo $event;
echo $persons;
}
?>
答案 0 :(得分:-1)
<input type="checkbox" class="ck" name="event" id="event" value="<?php echo $row['name'];?>" checked><span>Wybierz</span>
once embed this line of code in function its OK other wise go below
我执行了与我的数据库相同的代码。我认为你在$ row中有错误[&#39; column_name&#39;] .once check column_name