Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.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 isset($\U POST)有问题_Php_Html_Mysql - Fatal编程技术网

Php isset($\U POST)有问题

Php isset($\U POST)有问题,php,html,mysql,Php,Html,Mysql,我正在试着做登记表,但有点问题,我弄不清楚它在哪里 错误: 注意:未定义索引:用户名在。。。 注意:未定义索引:密码在 <form method="POST"> <?php if(isset($_POST['submit'])) { $username = $_POST['username']; $password = md5($_POST['password']);

我正在试着做登记表,但有点问题,我弄不清楚它在哪里

错误: 注意:未定义索引:用户名在。。。 注意:未定义索引:密码在

<form method="POST">
        <?php
            if(isset($_POST['submit'])) {
                $username = $_POST['username'];
                $password = md5($_POST['password']);

                if(empty($username) or empty($password)) {
                    echo "<p>Fields are empty!</p>";
                } else {
                    mysql_query("INSERT INTO users VALUES('', '$username', '$password', '2', '')");
                    echo "<p>Registration successful!</p>";
                }
            }
        ?>
        <p><label for="username">Username: </label><input type="text" id="username" /></p>
        <p><label for="password">Password: </label><input type="password" id="password" /></p>
        <input type="submit" name="submit" value="Sign up">
    </form>

谢谢

您需要输入名称:

<label for="username">Username: </label><input type="text" name="username" id="username" />
<label for="password">Password: </label><input type="password" name="password" id="password" />

这应该可以解决问题

简单:表单元素没有命名。另外,不要使用MD5,它很旧并且被认为是坏的。您的代码容易受到SQL注入的攻击。你应该继续读下去。评论再次被置若罔闻。祝你好运;你可能需要它。是的,我忘了定名字了。谢谢嗯,@Fred-ii-真的应该得到分数,但是他需要他们,我在发布答案,而我猜Fred在发布答案。但这是一个简单的解决办法,所以我相信很多其他人也知道这一点。