PHP奇怪的范围错误,空变量

时间:2013-07-18 17:26:16

标签: php scope

您好我有一个奇怪的范围问题

require 'connect.php';

$name = $_GET['R'];
echo $name;
if(isset($_POST['prev_password']) && isset($_POST['new_password']) && isset($_POST['rep_password'])) {
    echo $name;
    if(!empty($_POST['prev_password']) && !empty($_POST['new_password']) && !empty($_POST['rep_password'])) {
        $user_password = $_POST['prev_password'];
        $user_new_password = $_POST['new_password'];
        $user_rep_password = $_POST['rep_password'];

        if($user_new_password == $user_rep_password) {
            $mysql_query = sprintf("SELECT username, password FROM users WHERE username='$name'", $name);
            $query_run = mysql_query($mysql_query, $mysql_link) or die('COULD NOT PERFORM QUERY');

            while($row = mysql_fetch_array($query_run)) {
                $qUser_name = $row['username'];
                $qUser_pass = $row['password'];                
            }

            if($qUser_name == $name) {
                echo 'Match';
                if($qUser_pass == $user_password) {
                    $mysql_query = sprintf("UPDATE users SET password='$user_new_password' WHERE username='$name'", $name);
                    $query_run = mysql_query($mysql_query, $mysql_link) or die('COULD NOT PERFORM QUERY');
                    echo header('Location: main.php?C=1');                    
                }else {
                    header('Location: main.php?C=4');
                }
            }
        }else {
            header('Location: main.php?C=3');
        }
    }else {
        header('Location: main.php?C=2');
    }
}

无论如何,问题在于第一个变量$ name,当我'echo'$ name ok,正确显示内容,但在(如果是sss)ITS EMPTY内,idk为什么,我尝试过使用global, GLOBALS数组,它仍然是空的......所以...查询用空参数执行。

请帮助,如果有人能看到可能出现的错误。

PD:这是一个Changepassword.php $ _GET ['R']来自用户Main.php网站,我知道,我不是哈希密码,这不是真正的问题

0 个答案:

没有答案