PHP文件显示空白页面

时间:2014-08-21 10:52:37

标签: php html

我有一个登录页面,用户必须输入他在注册时使用的电子邮件ID。 点击提交后,它会重定向到verify.php 如果电子邮件ID正确,(用于存储注册信息,使用DB。)verify.php重定向到download.php页面。 登录在localhost上工作正常。(Xampp) 但在实现之后,将重定向提交到verify.php,但显示空白页面。 应用错误报告后,将出现以下错误。 查找以下错误和verify.php文件的附件。

<?php
error_reporting(E_ALL);
ini_set('display_errors','1');

$db = new mysqli("localhost", "root", "", "testembark");

$email = $_POST['email'];
$email = stripslashes($email);
$sql = "SELECT * FROM signup WHERE email='$email'";
$result = mysqli_query($db,$sql) or die(mysqli_error($db));

$row_cnt = mysqli_num_rows($result);

if($row_cnt==1){

    session_start();

    $_SESSION['email']= $email;


    header("location:download-product.php");
else {
    echo "Wrong Email";
}

?>

Errors

4 个答案:

答案 0 :(得分:1)

您的数据库连接失败。在继续使用连接之前,应始终检查连接是否成功。

$db = new mysqli("localhost", "root", "", "testembark");
if ($db->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

这样,在尝试使用不存在的连接之前,脚本就会消失。
此外,在您阻止之前,您错过了}
您也应该迁移数据库,只移动项目dir不会。查找移动数据库的说明here
请注意:您的连接详细信息将更改为您在服务器上的内容,例如$db = new mysqli("domain", "username", "password", "database");

答案 1 :(得分:1)

在localhost(Xampp)中无需为数据库提供密码,但在实时中,您拥有数据库的密码。

所以在这里提一下你的密码$ db = new mysqli(“localhost”,“root”,“你的数据库密码”,“testembark”);

答案 2 :(得分:0)

数据库登录似乎有误,你忘记了&#39;}&#39; char,那里:

if($row_cnt==1){
    session_start();

    $_SESSION['email']= $email;

    header("location:download-product.php");

// THERE
}else{
    echo "Wrong Email";
}

答案 3 :(得分:0)

$db = new mysqli("localhost", "root", "", "testembark");

我认为问题出在这里。

据我了解,一切都在本地计算机上运行正常,但在真实服务器上它失败了。 您需要检查用户名和密码是否适合安装在真实服务器上的数据库。