Javascript 烦人的通知:未定义索引:代码
我一直在寻找这个问题的答案已经3个小时了,但我不能删除这个恼人的通知…谁能帮我一下吗…它一直弹出'通知:未定义索引:代码 代码如下:Javascript 烦人的通知:未定义索引:代码,javascript,php,html,Javascript,Php,Html,我一直在寻找这个问题的答案已经3个小时了,但我不能删除这个恼人的通知…谁能帮我一下吗…它一直弹出'通知:未定义索引:代码 代码如下: <?php function randomcode() { $var = "abcdefghijkmnopqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; $code = '' ; wh
<?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
?>
代码:
为了消除这种错误,我已经阅读了很多教程,但都没有成功…我需要你们的帮助:禁用的元素不会发布到服务器
在这里,您禁用了名为code的输入元素,因此$\u 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;" >
如何在不使用disable的情况下使我的输入文本不可键入?@eloginko你可以使用ReadOnlyTanks来获得帮助
<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;" >