我已经看了这个问题的答案已经3个小时了但是我不能删除这个恼人的通知......任何人都可以帮助我...它保持pop-ping'注意:未定义的索引:代码。
继承人代码:
<?php
function randomcode() {
$var = "abcdefghijkmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
$code = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($var, $num, 1);
$code = $code . $tmp;
$i++;
}
return $code;
}
?>
<!--scripts ends here-->
<?php
if(isset($_POST['save']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$position = $_POST['position'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$repcode = $_POST['code'];
$contact = $_POST['contact'];
$age = $_POST['age'];
$dateregistered = date("Y-m-d H:i:s");
if (!$_POST['fname'] || !$_POST['lname'] || !$_POST['position'] || !$_POST['username'] || !$_POST['password'] || !$_POST['email'] || !$_POST['gender'] || !$_POST['code'] || !$_POST['conctact'] || !$_POST['age'] || !$_POST['code'] ){
?>
<script>
$(document).ready(function() {
// show a dialog box when clicking on a link
$.Zebra_Dialog('<strong>Try Again! </strong>' +
'You did not complete all of the required fields!', {
'type': 'warning',
'title': 'Non-uniformed Personnel (NUP)'
});
});
</script>
<?php
}
else
{
$query="INSERT INTO users (position, fname, lname, username,password,dateregistered,repcode,email,age,gender,contact) VALUES ('$position','$fname','$lname','$username','$password',CURRENT_TIMESTAMP,'$repcode','$email','$age','$gender','$contact') ";
mysql_query($query);
if($query){
// append here your jquery code
?>
<script>
$(document).ready(function() {
// show a dialog box when clicking on a link
$.Zebra_Dialog('<strong>Congratulations! </strong> <br> ' +
'You have successfully registered!', {
'type': 'confirmation',
'title': 'Non-uniformed Personnel (NUP)'
});
});
</script>
<?php
}
}
}
//corrected indentation
?>
代码:
<form action="registration.php" method="post">
<table align="center" width="100%" height="" bgcolor="#FFFFFF">
<tr>
<td align="center">
<table width="100%">
<tr>
<td>
<font face="Arial Black, Gadget, sans-serif" size="+2" color="#333333"><center>Registration Area</center></font>
<table border width="100%">
<tr>
<td>
<font color='dark orange'>*</font><font color='black'>First Name:</font>
<input type="text" name="fname">
</td>
<td> | </td>
<td>
<font color='dark orange'>*</font><font color='black'>Rep Code:</font>
<input type="text" name="code" disabled value="<?php echo randomcode() ?>" STYLE="color: #FF3; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;" >
</td>
</tr>
<tr>
<td>
<font color='dark orange'>*</font><font color='black'>Last Name:</font>
<input type="text" name="lname">
</td>
<td> | </td>
<td>
<font color='dark orange'>*</font><font color='black'>E-mail:</font>
<input type="text" name="email">
</td>
</tr>
<tr>
<td>
<font color='dark orange'>*</font><font color='black'>Rank:</font>
<select name="position" style="WIDTH: 200px">
<option></option>
<option>PINSP</option>
<option>PSINSP</option>
<option>PCINSP</option>
<option>PSUPT</option>
<option>PSSUPT</option>
<option>PCSUPT</option>
<option>NUP 1st level Rep.</option>
<option>NUP 2nd level Rep.</option>
<option>NUP 3rd level Rep.</option>
</select>
</td>
<td> | </td>
<td>
<font color='dark orange'>*</font><font color='black'>Age:</font>
<input type="text" name="age">
</td>
<tr>
<td>
<font color='dark orange'>*</font><font color='black'>Username:</font>
<input type="text" name="username">
</td>
<td> | </td>
<td>
<font color='dark orange'>*</font><font color='black'>Gender:</font>
<select name="gender" style="WIDTH: 200px">
<option></option>
<option>Male</option>
<option>Female</option>
</select>
</td>
</tr>
<tr>
<td>
<font color='dark orange'>*</font><font color='black'>Password:</font>
<input type="text" name="password">
</td>
<td> | </td>
<td>
<font color='dark orange'>*</font><font color='black'>Contact number:</font>
<input type="text" name="contact">
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>
<input type="submit" value="Create Account" name="save" />
</form>
</td>
</tr>
</table>
我已经厌倦了许多教程已经删除了这种错误但没有工作...我需要你的帮助人员:(
答案 0 :(得分:2)
disabled
元素不会发布到服务器。
在这里,您禁用了名为code
的输入元素,因此$_POST['code']
将导致未定义的索引通知。
<input type="text" name="code" disabled value="<?php echo randomcode() ?>" STYLE="color: #FF3; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;" >