PHP页面显示第一个else $errormessage而不检查代码


PHP page displaying first else $errormessage without checking code

我一直在尝试创建一个成员登录页面链接到我的网站。我有许多嵌套的If在我的PHP页面,但无论我怎么尝试,我收到$errormsg从第一个else语句。

我设法改变这一点的唯一方法是在代码底部(在表之前)添加一个额外的空else,当我单击reigisterbtn时,我要么收到第一个else结果,要么收到一个空白页面。

我是否错过了一些非常明显的东西?

 <?php
error_reporting (E_ALL ^ E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Register Page</title>
</head>
<body>
<?php


if ( $_POST ['registerbtn']) {
  $getuser =$_post ['user'];
  $getemail =$_post ['email'];
  $getpass =$_post ['pass'];
  $getretypepass =$_post ['retypepass'];


    if($getuser){
        if ($getemail){
            if ($getpass){
                if ($getretypepass){
                    if ($getpass === $getretypepass){
                        if ((strlen ($getemail) >=7 ) && (strstr ($getemail, "@")) && (strstr ($getemail, "."))) {
                                require ("./connect.php");
                                $query = mysql_query ("SELECT * FROM users WHERE username ='$getuser'");
                                $numrows = mysql_num_rows ($query);
                            if ($numrows == 0){
                                                $query = mysql_query ("SELECT * FROM users WHERE email ='$getemail'");
                                                $numrows = mysql_num_rows ($query);

                                if ($numrows == 0){
                                                            $password =md5 (md5 ("kjfiufj".$password."Fj56fj"));
                                                            $date("F d, Y");
                                                            $code = md5(rand ());
                                                            mysql_query ("INSERT INTO users VALUES (
                                                            '', '$getuser','$password','$getemail', '0', '$code', '$date')");
                                                                    $query = mysql_query ("SELECT * FROM users WHERE username='$getuser'");
                                                                    $numrows = mysql_num_rows ($query);

                                    if ($numrows == 1){
                                                                            $site = "http://www.andyhoole.co.uk";
                                                                            $webmaster = "AndyHoole <admin@andyhoole.co.uk>";
                                                                            $headers = "From: $webmaster";
                                                                            $subject = "Activate your account";
                                                                            $message = " Thank you for registering :) . Clink the link below to activate your account.'n ";
                                                                            $message .="$site/activate.php?user=$getuser&code=$code'n";
                                                                            $message .= "You must activate your account to log in.";
                                        if ( mail($getemail,$subject, $message, $headers) ){
                                                        $errormsg = "You have been registered, you must activate your account form the activation link sent to <b> $getemail </b>";
                                                        $getuser = "";
                                                        $getemail = "";
                                        }else
                                            $errormsg = "An error has occured. Your activation email was not sent.";


                                    }else
                                        $errormsg = " An error has occured and your account has not been created. ";
                                }else
                                    $errormsg = " This email address already exsists.";         
                            }else
                                $errormsg = " This username already exsists.";              
                                        mysql_close();
                        }else
                            $errormsg = "You must enter a valid email address to register.";
                     }else
                        $errormsg = "Your passwords did not match.";
                 }else
                    $errormsg = "You must retype your password to register.";
            }else
                $errormsg = "You must enter your password to register.";
        }else
            $errormsg = "You must enter your email address to register.";
    }else
        $errormsg = "You must enter your User name to register.";

}

$form = "<form action='./register.php' method='post'>
<table>
<tr>
    <td></td>
    <td><font color='red'>$errormsg</font></td>
</tr>
<tr>
    <td>Username:</td>
    <td><input type='text' name='user' value='$getuser' /></td>
</tr>
<tr>
    <td>Email:</td>
    <td><input type='text' name='email' value='$getemail' /></td>
</tr>
<tr>
    <td>Password:</td>
    <td><input type='password' name='pass' value='' /></td>
</tr>
<tr>
    <td>Retype:</td>
    <td><input type='password' name='retypepass' value='' /></td>
</tr>
<tr>
    <td></td>
    <td><input type='submit' name='registerbtn' value='Register' /></td>
</tr>

</table>
</form>";

echo $form;

?>
</body>
</html>

感谢您的收看:)

您还应该使用$_POST而不是$_post,因为php是区分大小写的!