0

私は自分のウェブサイトにリンクするためのメンバーログインページを作成しようとしています。PHPページ内にネストされたIfがいくつかありますが、何を試しても、最初のelseステートメントから$errormsgを受け取ります。

これを変更する唯一の方法は、コードの下部(テーブルの前)に空の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>

見てくれてありがとう:)

4

1 に答える 1

1

phpでは大文字と小文字が区別されるため、$_POST代わりに使用する必要があります。$_post

于 2013-03-19T01:16:29.473 に答える