Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP页面显示第一个else$errormessage而不检查代码_Php_Html_Mysql - Fatal编程技术网

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

PHP页面显示第一个else$errormessage而不检查代码,php,html,mysql,Php,Html,Mysql,我一直在尝试创建一个会员登录页面来链接到我的网站。我的PHP页面中有许多嵌套的If,但是无论我怎么做,我都会从第一条else语句中收到$errormsg 我唯一能够改变这一点的方法是在代码底部(表格之前)添加一个额外的空else,当我单击reigisterbtn时,我要么收到第一个else结果,要么收到一个空白页,没有显示任何内容 我是不是错过了一些很明显的东西 <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE

我一直在尝试创建一个会员登录页面来链接到我的网站。我的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>

注册页

您还应该使用
$\u POST
而不是
$\u POST
,因为php是区分大小写的

您没有为sql查询设置任何错误处理指令,顺便说一句,您不应该首先使用
mysql.*
函数。到底抛出了什么错误?(“第一个else语句”是含糊不清的)关于设计选择,我本可以用一个数组进行错误检查,但不会像代码那样陷入更深的混乱,但这不是quesiton.vjones-在pal上,我已经看了大约12个小时的代码,没有注意到小写。非常感谢。