echo函数未显示任何输出

时间:2016-02-09 14:06:53

标签: php echo

<?php
session_start();

if (isset($_POST["user_name"]) && isset($_POST["user_pwd"])) {
    include"php/connect_to_mysql.php";
    $user_name = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_name"]);
    $user_pwd = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_pwd"]);

    $sql = "SELECT * FROM user_ac WHERE user='$user_name' OR email='$user_name' AND pwd='$user_pwd' LIMIT 1";
    $result = mysqli_query($myConnection, $sql);

    if (mysqli_num_rows($result) > 0) {
        echo "Successfully Logged In";
        header("location: login.html?abc=234");
    } else {

    }
} else {

}    

在此代码中,在第二个if语句中,echo未显示任何内容,但header函数正确执行。

请帮助,谢谢。

2 个答案:

答案 0 :(得分:3)

标题功能会将您重定向到新页面,因此您的回显将显示在当前页面中,但您的代码将显示在此行中:

header("location: login.html?abc=234");

会将您重定向到新页面。

答案 1 :(得分:1)

您无法看到回声,因为您要转到其他页面。

作为测试,请移除header("location: login.html?abc=234");,您会看到echo

相关问题