Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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 什么';我的电子邮件验证码有什么问题?_Php_Syntax Error_Html Email_Email Validation - Fatal编程技术网

Php 什么';我的电子邮件验证码有什么问题?

Php 什么';我的电子邮件验证码有什么问题?,php,syntax-error,html-email,email-validation,Php,Syntax Error,Html Email,Email Validation,好的,所以今天,我编辑了这段代码,这应该是为了让用户可以更改他们的电子邮件地址。他们更改电子邮件地址后,系统将向用户发送确认电子邮件。但是,我被重定向到一个内部错误500页:有什么帮助吗?我看不出代码有什么问题 <?php include("session.php"); //Create game account $mysqli = new mysqli("localhost", "root", "password", "data"); if(mysqli_connect_errno(

好的,所以今天,我编辑了这段代码,这应该是为了让用户可以更改他们的电子邮件地址。他们更改电子邮件地址后,系统将向用户发送确认电子邮件。但是,我被重定向到一个内部错误500页:有什么帮助吗?我看不出代码有什么问题

<?php

include("session.php");
//Create game account
$mysqli = new mysqli("localhost", "root", "password", "data");

if(mysqli_connect_errno()){
    echo("Sorry, the server is 'Under Maintainance'");
    exit();
}

$newemail = $mysqli->real_escape_string($_POST['email']);
$newemail = strtolower($newemail);
$password = $mysqli->real_escape_string($_POST['password']);
$hash     = sha1(strtolower($name) . $password);

if(!isset($name)){
    header("Location:index");
}else if($password == null || $password == "" || (strlen($password)) < 4 || strpos($password, '<') !== false || strpos($password, '>') !== false){
    header("Location:cemail?error=6");//Invalid password
}else if($newemail == null || $newemail == "" || (strlen($newemail) <= 6 || strpos($newemail, '<') !== false || strpos($newemail, '>') !== false) || strpos($newemail, '@') == false || strpos($newemail, ".com") == false){
    header("Location:cemail?error=7");//Invalid Email address
}else if($email == $newemail){
    header("Location:cemail?error=7");//Invalid Email address
}else{
    $result  = $mysqli->query("SELECT * FROM characters WHERE email='$newemail' && name!='$name");
    $row_cnt = $result->num_rows;
    $result->free();

    if($row_cnt != 0){
        header("Location:cemail?error=3");//Email already taken
    }else{

        $result  = $mysqli->query("SELECT * FROM characters WHERE originemail='$newemail' && name!='$name'");
        $row_cnt = $result->num_rows;
        $result->free();

        if($row_cnt != 0){
            header("Location:cemail?error=3");//Email already taken
        }else{

            $result = $mysqli->query("SELECT * FROM characters WHERE name='$name'");

            /* fetch associative array */
            while($row = $result->fetch_assoc()){
                $pass        = $row['pass'];
                $originemail = $row['originemail'];
            }

            /* free result set */
            $result->free();

            if($hash != $pass){
                header("Location:cemail?error=6");//Invalid Password Match
            }else{
                $mysqli->query("UPDATE characters SET email='$newemail' WHERE name='$name'");

//Send Email to confirm 
                $to      = $newemail . ", " . $originemail;
                $subject = "Your email address has now been successfully changed!";
                $body    = "This is a notification regarding the recent change(s) made to your Legion Online account: " . $username . "
\n\n
Your email address has recently been modified through the Legion Online website. If you made this email address change, please disregard this notification. If you did not change your email address, please visit the account recovery page to ensure your account is secure.\n\nEmail addresses connected to this account: \n" . $originemail . "(primary)\n" . $newemail;
                $headers = "From: AccountSupport@ArchStudios.net" . "\r\n";
                if(mail($to, $subject, $body, $headers)){
                    header("Location:accountsettings");
                }else{
                    echo "Email request failed.";
                }
            }
        }
    }
}
$mysqli->close();
?>

您只有一个按变量$name引用的引号:

$result=$mysqli->query("SELECT * FROM characters WHERE email='$newemail' && name!='$name");
复制此文件:

$result=$mysqli->query("SELECT * FROM characters WHERE email='$newemail' && name!='$name'");

不要忘记关闭单引号/双引号

替换

$mysqli = new mysqli("localhost", "root", "password", "data);
$result  = $mysqli->query("SELECT * FROM characters WHERE email='$newemail' && name!='$name");


查看错误日志并查看错误是什么。或者,如果找不到错误日志,请添加
ini\u set('display\u errors',1)
到文件顶部(在
的正下方,请注意,您编辑的密码仍在编辑历史记录中。您正在使用
$name
,但未在之前声明-
$hash=sha1(strtolower($name)。$password)
我强烈建议你在使用密码的任何地方都要更改密码。多亏了语法highlighterNote,在匿名化密码时,在“数据”后面缺少引号只是一个错误,而不是他遇到的实际问题。
$mysqli = new mysqli("localhost", "root", "password", "data");
$result  = $mysqli->query("SELECT * FROM characters WHERE email='$newemail' && name!='$name'");