Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP登录脚本“if(isset($\u POST['submit'])”不起作用_Php - Fatal编程技术网

PHP登录脚本“if(isset($\u POST['submit'])”不起作用

PHP登录脚本“if(isset($\u POST['submit'])”不起作用,php,Php,我的网站有一个PHP登录脚本,但ifisset$_POST['submit']似乎不起作用。它不断返回,echo无法登录。请与管理员联系。;。代码是 <?php error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); require "dbc.php"; if(isset($_POST['submit'])) { $username = mysql_real_escape_string($_

我的网站有一个PHP登录脚本,但ifisset$_POST['submit']似乎不起作用。它不断返回,echo无法登录。请与管理员联系。;。代码是

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();

require "dbc.php";
if(isset($_POST['submit']))
{
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $enc_password = md5($password);

    if($username && $password)
    {
        $query = mysql_query("SELECT * FROM users WHERE username='$username'");
        $numrow = mysql_num_rows($query);

        if($numrow!=0)
        {
            while($row = mysql_fetch_assoc($query))
            {
                $db_username = $row['username'];
                $db_password = $row['password'];
            }

            if($username==$db_username&&$enc_password==$db_password)
            {
                echo "Logged in <a href='membersarea.php'>Click here to enter the members area</a>";
                $_SESSION['username']=$db_username;
                header("location: membersarea.php");
            }
            else 
            {
                echo "Incorrect Username/Password";
            }
        }
        else 
        {
            echo "Incorrect Username/Password";
        }
    }
    else 
    {
        echo "All fields are required";
    }
}
else{
    echo "Unable to login.  Please contact administrator.";
}

?>
<!--V0.3.5 Alpha-->
这是您键入信息的页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="description" content="Home to  and its game downloads."/>
        <meta name="keywords" content="Games, Downloads, Free, Fun, Game Development, Roll Ball, "/>
        <meta name="author" />
        <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
        <title>

        </title>
    </head>
    <body>
        <div id="validxhtml">
            <p>
                <a href="http://validator.w3.org/check?uri=referer"><img
                src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
            </p>
        </div>
        <div id="validcss">
        <p>
            <a href="http://jigsaw.w3.org/css-validator/check/referer">
                <img style="border:0;width:88px;height:31px"
                    src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
                    alt="Valid CSS!" />
            </a>
        </p>

    </div>
        <div id="title">
            <h1 class="hcenter"></h1>
        </div>
        <div id="subtitle"><h2 class="hcenter">Login</h2></div>
        <div id="links">
            <ul>
                <li><a href="index.html" title="Home">Home</a></li>
                <li><a href="game.html" title="Current Games">Games</a></li>
                <li>Login</li>
                <li><a href="contact.html" title="Contact Me">Contact Me</a></li>
            </ul>
        </div>
        <div id="body"><h3>Please Login</h3>
         <?php if(isset($_GET['error'])){echo $_GET['error'];echo "<br />";} ?>
            <form action="login.php" method="POST">
                    Username: <input type="text" name="username"><br>
                    Password: <input type="password" name="password"><p>
                <input type="submit" value="Login"> 
            </form>

            <a href="register.php">Don't have an account?  Register here.</a>
        </div>
        <div id="policy" class="hcenter">
            <a target="_blank" href="http://privacypolicies.com/privacy/view/PUlI8q">Privacy policy</a>
        </div>
            <script type="text/javascript">
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-73371388-2', 'auto');
  ga('send', 'pageview');

</script>
    </body>
</html>
<!--V0.3.5 Alpha-->

我还有最后一件事要说,第二个脚本是您输入登录信息的脚本,当您单击“登录”时,它会将其指向第一个脚本。如果您有任何问题,请随时问我。

您的html代码中没有任何name=submit的输入,因此跳过了If子句

改变

<input type="submit" value="Login"> 
致:


html代码中没有name=submit的任何输入,因此跳过了if子句

改变

<input type="submit" value="Login"> 
致:


非常感谢你!它是有效的,我真不敢相信这个错误有多愚蠢。没问题,别忘了选择最好的答案:D这个答案的对勾部分我不得不再等9分钟,因为网站不允许我。非常感谢!这是可行的,我真不敢相信这个错误有多愚蠢。没问题,别忘了选择最佳答案:D这个答案的对勾部分我必须再等9分钟,因为网站不允许我。你在代码中使用了mysql_*函数。请看这个关于为什么应该远离它们的问题:您正在代码中使用mysql_*函数。请看这个关于为什么你应该远离他们的问题: