以下是一个登记程序:如果输入了空白认证码时,会弹出讯息
当页面是utf8,gb2312时,便会重复2次弹出讯息
只有用big5,只弹出一次
Firefox沒有問題,只出一次, ie便出了2次请问如何解决?谢谢<?php
function alertMessage($msg){
echo "<script>alert('".$msg."');</script>";
}if(isset($_POST['signup'])){
if($_POST['validcode']!=""){
     if($_POST['validcode']!=$_SESSION['checkkey']){
alertMessage('wrong code');
     }
}
else{
    alertMessage('code is null');
}
}//isset
?>
<html>
<body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>signup</title>
<script type="text/javascript">
function signupSubmit(){
//alert(document.signupform.signuptype.name);
if(document.signupform.signuptype.checked==true){
if(document.signupform.username.value==""){
alert("plesae input the username");
return false;
}
}
return true;
}
</script>
</head> <form action="" method="post" name="signupform" onSubmit="return signupSubmit();">
<p><input type="checkbox" name="accept">&nbsp;Accept</p>
<p><input type="text" name="validcode" size="5" maxlength="4">&nbsp;<img src="validcode.php"></p>
<p><input type="submit" name="signup" value="signup" class="button"></p>
</form>
</body>
</html>

解决方案 »

  1.   

    那么应该如何判断才正确?
    是否这里出错?谢谢
    if(isset($_POST['signup']))
      

  2.   

    我也碰到过这样的问题,解决方法是把弹出放到HTML的最后面
    <?php
    $msg = "hello";
    ?>
    <html>
    <body>
    ..........
    <script type="text/javascript">
    <?php if(isset($msg)) echo "alert('".$msg."')";?>
    </script>
    </body>
    </html>
      

  3.   

    http://community.csdn.net/Expert/topic/5280/5280420.xml?temp=.4943811
      

  4.   

    如果用"redlee520(双飞) "的方法是可以,但submit后load页面时出了一半画面,才弹出讯息,要按了确定才有下一半页面显示,很怪啊。
    还有其他方法吗?
      

  5.   

    那就用ajax吧!!不用服务器端输出弹出