我的 php 文件中有以下代码:
$p_adminType = $_POST['adminType'];
$p_adminUserID = $_POST['userID'];
$p_adminUserPass = $_POST['userPass'];
$p_firstName = $_POST['adminFirstName'];
$p_lastName = $_POST['adminLastName'];
然后,当我通过单击 html 文件中的提交按钮来执行文件时,我收到一条通知错误消息:
Notice: Undefined index: userID in C:\wamp\www\CaNeCo\CaNeCo_Admin_Reg.php on line 19
Notice: Undefined index: userPass in C:\wamp\www\CaNeCo\CaNeCo_Admin_Reg.php on line 20
Notice: Undefined index: adminFirstName in C:\wamp\www\CaNeCo\CaNeCo_Admin_Reg.php on line 21
其中你可以从代码中看到第 19、20 和 21 行所在的位置。我尝试将 isset() 函数添加到我的代码中,就像我从其他网站/论坛中阅读的内容一样,但是当我这样做时,它并不能解决我的问题。它只隐藏错误消息,变量仍然为空。
我该如何解决这个问题?另外,我只是想知道为什么它只发生在 5 个声明中的 3 个上?$p_adminType = $_POST['adminType'];
并且$p_lastName = $_POST['adminLastName'];
工作正常但不是其他3?有人可以告诉我吗?
这是我拥有的 html 文件:
<form method="post" action="CaNeCo_Admin_Reg.php">
<table width="400">
<tr>
<td><b>Log-in Information:</b></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Administrator Type:</td>
<td>
<select name="adminType" id="adminType">
<option value="0">Please Select</option>
<option value="1">Super Administrator</option>
<option value="2">Administrator</option>
<option value="3">Secretary</option>
<option value="4">Viewer</option>
</select>
</td>
</tr>
<tr>
<td>User ID: </td>
<td><input type="text" name:"userID" id="adminUserID" placeholder="User I.D." maxlength="20" size="35"/></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name:"userPass" id="adminUserPass" placeholder="Password" maxlength="25" size="35"/></td>
</tr>
<tr>
<td>Repeat Password:</td>
<td><input type="password" name="repeatPass" id="adminRepeatPass" placeholder="Repeat Password" maxlength="25" size="35"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan="25"><b>Personal Information:</b></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>First Name: </td>
<td><input type="text" name:"adminFirstName" id="adminFirstName" placeholder="First Name" maxlength="20" size="35"/></td>
</tr>
<tr>
<td>Last Name: </td>
<td><input type="text" name="adminLastName" id="adminLastName" placeholder="Last Name" maxlength="25" size="35"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan="50"><center><input type="submit" value="Submit"/></center></td>
</tr>
</table>