Php 登录页面让我困惑,为什么赢了';这不管用吗?

Php 登录页面让我困惑,为什么赢了';这不管用吗?,php,mysql,Php,Mysql,你好!我简直无法理解为什么这个登录页面不能工作。我以前使用PHP5.4在共享服务器上运行过它。我把网站移到了自己的服务器上,运行Ubuntu 12.04、apache 2.4.6、PHP5.5 我只是在下面展示整个登录文件,globals.php包含mysql连接,可以正常工作 如果我遗漏了任何信息,请告诉我 简单地通过在if语句中测试print语句,我认为在if(prepare)之后是失败的 问题是,在您尝试登录后,if语句后面会显示一个空白页 再次感谢您的帮助,如果我没有提供足够的信息,请告

你好!我简直无法理解为什么这个登录页面不能工作。我以前使用PHP5.4在共享服务器上运行过它。我把网站移到了自己的服务器上,运行Ubuntu 12.04、apache 2.4.6、PHP5.5

我只是在下面展示整个登录文件,globals.php包含mysql连接,可以正常工作

如果我遗漏了任何信息,请告诉我

简单地通过在if语句中测试print语句,我认为在if(prepare)之后是失败的

问题是,在您尝试登录后,if语句后面会显示一个空白页

再次感谢您的帮助,如果我没有提供足够的信息,请告诉我

我有一种感觉,它与mysqli连接vs mysql vs PDO有关

    <?php 
include( "globals.php" ); 
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<?php 
newHead("GWHS Login", "/css/style.css"); //@param: title of site, link to css (default: http://gwhs.kana.k12.wv.us/css/style.css 
?>
    <body>
<?php 
newBorder(); //create page border @param: width of border in px (default: 5px) 
newLogo();

if (($_POST['username']) && ($_POST['password']))
{
$user = $_POST['username']; 
$pass =  md5($_POST['password']); 
$stmt = $db->stmt_init();
if ($stmt->prepare("SELECT id, username, password FROM updateusers WHERE username = ? and password = ? LIMIT 1"))
{
$stmt->bind_param('ss', $user, $pass);
$stmt->execute();
$res = $stmt->get_result();
$row = $res->fetch_assoc();
    if ($res->num_rows==1)
    {
    $_SESSION['username'] = $user; 
    $_SESSION['userid'] = $row['id'];
    $_SESSION['type'] = 1;
    $_SESSION['LAST_ACTIVITY'] = time();
    print "<script>alert('You are logged in! Check the menu \"Admin\" section for more information!');</script>";
    }
    else {
    echo "<script>alert('Wrong user / pass');</script>";
    }
$stmt->close();
}
}
?>
    <div id = "wrap"> <!-- Used to constrain the page width to 70% and center the page.  -->
        <?php 
        $links = array( array("Link to page", "Title of page"), //LEAVE BLANK IF USING MAIN MENU
               array("Link to page 2", "Title of page 2"),
               array("Link to page 3", "Title of page 3") 
             ); 
        newNavigation (); //create menu @param: $use boolean, use the main? and $links = if not using main, what are your links NO DROPDOWN SUPPORT.  
        ?>
            <div id ='main'> <!-- This is the left block of the main content -->
                <h1>GWHS Editor Login</h1>
                <form method = "POST" action = "login.php">
                    Username: <input type="text" name="username"><br>
                    Password: <input type="password" name="password"><br>
                    <input type="submit" value="Login">
                </form>
            </div>
            <?php newSidebar(); //creates new sidebar?>

<?php 
newFooter();    //displays footer @param: $content (default: 'Copyright (c) 2012 - 2013, Design : <a href = "http://ankurk.com">AK</a>')    
?>
    </div> 
    </body>
</html>

尝试更改此选项

 $stmt->bind_param('ss', $user, $pass);
$stmt->execute();
$res = $stmt->get_result();
$row = $res->fetch_assoc();
if ($res->num_rows==1)
{
 $_SESSION['username'] = $user; 
$_SESSION['userid'] = $row['id'];
$_SESSION['type'] = 1;
$_SESSION['LAST_ACTIVITY'] = time();
print "<script>alert('You are logged in! Check the menu \"Admin\" section for more information!');</script>";
}
$stmt->bind_参数('ss',$user,$pass);
$stmt->execute();
$res=$stmt->get_result();
$row=$res->fetch_assoc();
如果($res->num_rows==1)
{
$\会话['username']=$user;
$\会话['userid']=$row['id'];
$\会话['type']=1;
$\会话['LAST\ u ACTIVITY']=time();
打印“警报('您已登录!有关详细信息,请查看“管理”菜单部分!”);
}

$stmt->bind_参数('ss',$user,$pass);
$stmt->store_result();
$stmt->execute();
如果($stmt->num_rows==1)
{
$stmt->bind_result($id、$username、$password);
$stmt->fetch();
打印“警报('您已登录!有关详细信息,请查看“管理”菜单部分!”);
}

新服务器上是否存在您的表?值得思考的是:不要使用
md5
存储密码您是否有
session_start()在所有页面中?没有提到。弗雷德,目前最好的方法是什么?$pass=hash($sha256,$_POST['password']);另外,是的,会话是在globals.php中启动的。很抱歉尝试将此代码放在页面顶部,查看ini_集合('display_errors','1')中出现的错误echo_Me,$res不是未定义的吗?@ankurkdotcom yes没有看到它,更新了我的答案。结果发现我禁用了错误,没有看到get_结果是错误。所以我没有安装mysqlnd,在安装之后我的问题就解决了!
 $stmt->bind_param('ss', $user, $pass);
 $stmt->store_result();
 $stmt->execute();

if ($stmt->num_rows==1)
{
$stmt->bind_result($id, $username, $password);
$stmt->fetch();
print "<script>alert('You are logged in! Check the menu \"Admin\" section for more information!');</script>";
}