登录php代码什么都没做?

时间:2016-06-10 21:07:07

标签: php html

我使用一个简单的文本文档,在我的网站目录public_html / USERS / Matt / password.txt中保存一个密码,现在我的代码问题就是按下我的提交按钮时似乎没有任何事情发生。我确定这只是一个愚蠢的错误,任何人都有任何想法吗?

<?php
ob_clean();session_start(); 
if (isset($_GET['logout'])){
    session_destroy();  
}

$Username = $_POST['username'];
$EnteredPassword = $_POST['password'];

if (isset($_POST['submit'])){
    if (is_dir("USERS/".$Username) === true){
        $myFile=fopen("USERS/".$Username."/Password.txt","r") or exit("Can't open file!");
        $CorrectPassword = fgets($myFile);
        fclose($myFile);

        echo 'Username found.';

        if ($CorrectPassword == $EnteredPassword){
            echo 'Login successful.';   
        }

        else {
            echo 'Password incorrect.';
        }
    }

    else {
        echo 'Username not found.';
    }

    echo 'Checking if username is found...';
}

?>

<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Project Archive - Login</title>

        <link href="CSS/master.css" rel="stylesheet" type="text/css">
        <script src="JAVASCRIPT/respond.min.js"></script>
    </head>
    <body>
    <div id="containerDiv">
        <div id="titleDiv">
            <font size="20pt">
                <p align="center">Project Archive</p>
            </font>

            <div id="loginBoxDiv">
                <form method="post" action="index.php">
                    <div id="username">
                        <p>Username:</p>
                        <input type="text" name="username" size="12">
                    </div>

                    <div id="password">
                        <p>Password:</p>
                        <input type="password" name="password" size="12">
                    </div>

                    <div id="btnLogin">
                        <input id="button" type="submit" value="Login">
                    </div>
                </form>
            </div>

        </div>
    </div>
    </body>
</html>

1 个答案:

答案 0 :(得分:2)

为提交按钮添加名称

<div id="btnLogin">
     <input id="button" name='submit' type="submit" value="Login">
 </div>