1

我目前正在制作一个登录表单,虽然据我所知,当我尝试登录时没有错误,但是,它没有显示任何成功消息或任何信息,所以我不知道我是否成功登录.

<?php
        session_start();
        require_once('sqlconnect.inc.php');

        if (isset($_POST["Login"]))
        {
        $conn = @mysqli_connect($host, $user, $pswd);
                    if (!$conn) {
                    echo "<p>Database connection failure</p>"; 
                    } else {

        $selectDatabase = @mysqli_select_db($conn,$dbnm)
                    or die("<p>The database is not available.</p>");
                    }

        $email = $_POST['email'];
        $passw = $_POST['password'];

        $query = "SELECT member_email FROM team WHERE member_email = '$email' AND password = '$passw'";

        $queryResult = @mysqli_query($conn,$query)
                        or die ("<p>Unable to execute query.</p>". "<p>Error code" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>";


        if(mysqli_num_rows($queryResult) == 0) //user is not found
        {
            header('Location: login.php');
        }else{

        if(mysqli_num_rows($queryResult) == 1)  
        {
            echo ("<p>User is found, Successful login!</p>");   
            echo('<p><a href="memberadd.php">member add</a> </p>');
            echo('<p><a href="logout.php">Log out</a> </p>');

            $query2 = "SELECT member_name FROM team WHERE member_email = '$email' AND password= '$passw'";

            $queryResult2 = @mysqli_query($conn, $query2)
                        or die ("<p>Unable to execute query.</p>". "<p>Error code" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>";


            $array = mysqli_fetch_row($queryResult2);       
            $_SESSION['membername'] = $array[0];
        }
        else
        {
            echo"<p>Email and password do not match</p>";
            echo'<p><a href="index.php">Home page</a> </p>';
        }
        }
        }


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/chtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="description" content="Web Programming :: Assignment 2" />
    <meta name="Keywords" content="Web, programming" />
    <title>Register Page</title>
</head>

<body>

<form id='login' action='login.php' method='POST'>
        <fieldset >
            <legend><h1>My Team System Log in Page</h1></legend>
            <?php $email = isset($_POST['email']) ? filter_var($_POST['email'], FILTER_SANITIZE_STRING) : ''; ?>
            <label for='email' >Email:</label>
                <input type='text' name='email' id='email' maxlength="50"  value="<?php echo $email; ?>" />
            </div>
                    <br />
            <div class="elements">
            <label for='password' >Password:</label>
                <input type='password' name='password' id='password' maxlength="50" />
            </div>
                    <br />
            <div class="submit">
                <input type='submit' name='login' value='Login' />
                <input type='reset' name='Submit' value='Clear' />
                    <br />
            <div class="elements">
            <a href="index.php">Home</a> 
        </fieldset>
</form>

</body>
</html>
4

1 回答 1

0

要么您有来自使用 @ 屏蔽的 mysql 调用的错误,要么是您正在调用标头函数的代码块。如果您删除 @ 和/或将标头调用替换为纯文本会发生什么

echo "Debug: Test";
于 2013-10-30T19:56:37.847 回答