简体   繁体   English

PHP登录(表单提交到loginprocess.php的链接,但没有任何反应(空白页))

[英]PHP Login (Form submit links to loginprocess.php but nothing happens(blank page))

I'm trying to create a login page using Mysql, I checked DB connection and such everything works as intended. 我试图使用Mysql创建一个登录页面,检查了数据库连接,并且一切正常。 However I've created the loginprocess now but when submitting the login information it just links me to the loginprocess.php and nothing else happens. 但是,我现在已经创建了loginprocess,但是在提交登录信息时,它只是将我链接到loginprocess.php,而没有任何其他反应。 I tried searching for a while but everyone's issue what that they didn't give the username input a name. 我尝试搜索了一段时间,但是每个人的问题是他们没有给用户名输入一个名称。

Here's my code for the index.php (login screen) 这是我的index.php代码(登录屏幕)

<?php
include_once 'header.php';
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">

<body>
<header>

</header>

<section>

    <div class="nav-login">
    <form action="includes/loginprocess.php" method="POST">
        <input class="txtbox" type="text" name="username" placeholder="Username"><br>
        <input class="txtbox" type="password" name="userpass" placeholder="Password"><br>
        <button class="good-looking" type="submit" name="submit">Login</button> 
    </form>

    </div>
</section>

</body>
</html>

and this is the loginprocess.php (it's in includes folder) 这是loginprocess.php (位于includes文件夹中)

 <?php
session_start();

if(isset($_POST['submit'])) {
    include 'dbconn.php';

    $username = mysqli_real_escape_string($conn, $_POST['username']);
    $userpass = mysqli_real_escape_string($conn, $_POST['userpass']);

    if (empty($username) || empty($userpass)) {
        header("Location: ../index.php?login=empty");
        exit();
    } else {
        $sql = "SELECT * FROM samokslogin WHERE samokslogin_username='$username'";
        $result = mysqli_query($conn, $sql);
        $reultCheck = mysqli_num_rows($result);
        if($resultCheck < 1) {
        header("Location: ../index.php?login=error");
        exit();
        } else {
            if($row = mysqli_fetch_assoc($result)) {
                $LoginCheck = password_verify($pwd, $row['samokslogin_userpass']);
                if($LoginCheck == false) {
                    header("Location: ../index.php?login=failed");
                    exit();
                } elseif ($LoginCheck == true) {
                $_SESSION['u_id'] = $row['samokslogin_id']; 
                $_SESSION['u_username'] = $row['samokslogin_username']; 
                header("Location: ../index.php?login=success");
                exit();
                }
            }
        }
    }

} else {
        header("Location: ../index.php?login=failed");
        exit();
    }

I really did search for a long time, and re-read all my codes to make sure I've even tried using try catch to see the error but nothing came up. 我确实做了很长时间的搜索,然后重新阅读了我所有的代码,以确保我什至尝试使用try catch来查看错误,但没有任何反应。 I hope I'm not missing something obvious.. 我希望我不要错过明显的东西。

Best regards :) -Samo 最好的问候:)-萨摩

在检查了错误日志后,我忘记了$ username = mysqli_real_escape _string ($ conn,$ _POST ['username']),从而犯了一个小错误,我已经修复了它,这要感谢所有帮助我解决了这个问题的人第一个php项目我什至不确定是否有错误日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM