该复选框无法正常工作。它有 3 个复选框。当我选择所有三个复选框时,我没有收到任何错误。但是当我选择 1 或 2 复选框时,我收到如下错误:
注意:未定义的索引:第 16 行 C:\wamp\www\test\secpage.php 中的 chke
<html>
<body>
<table>
<form method="post" action="secpage.php">
<tr>
<td colspan="2"><center><h4>Registartion Form</h4></center></td>
</tr>
<tr>
<td>Username : </td>
<td><input type="text" name="txtname" value=""/></td>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" name="txtpass" vale=""/></td>
</tr>
<tr>
<td>Email : </td>
<td><input typ="text" name="txtemail" value=""/></td>
</tr>
<tr>
<td>Address : </td>
<td><textarea name="add" /></textarea></td>
</tr>
<tr>
<td>Subjects : </td>
<td><input type="checkbox" name="chkm" value="Maths"</td>Maths
<td><input type="checkbox" name="chks" value="Science"</td>Science
<td><input type="checkbox" name="chke" value="English"</td>English
</tr>
<tr>
<td>Gender : </td>
<td><input type="radio" name="gen" value="Male"/>Male
<input type="radio" name="gen" value="Female"/>Female
</td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" value="Submit"/></center></td>
</tr>
</body>
</html>
这是php页面:
<html>
<body>
<?php
$uname=$_POST["txtname"];
$pass=$_POST["txtpass"];
$email=$_POST["txtemail"];
$add=$_POST["add"];
$subm=$_POST["chkm"];
$subs=$_POST["chks"];
$sube=$_POST["chke"];
$gen=$_POST["gen"];
?>
<table>
<tr>
<td>Username : </td>
<td><?php echo $uname; ?></td>
</tr>
<tr>
<td>Password : </td>
<td><?php echo $pass; ?></td>
</tr>
<tr>
<td>Email : </td>
<td><?php echo $email; ?></td>
</tr>
<tr>
<td>Address : </td>
<td><?php echo $add; ?></td>
</tr>
<tr>
<td>Subject Selected : </td>
<td><?php echo $subm." ".$subs." ".$sube; ?></td>
</tr>
<tr>
<td>Gender : </td>
<td><?php echo $gen ?></td>
</tr>
</table>
</body>
</html>
任何帮助将不胜感激。