简体   繁体   English

isset($ _ POST)出了点问题

[英]Something wrong with isset($_POST)

I'm trying to make registration form, but there is some problem, I can't get where it is. 我正在尝试制作注册表,但是存在一些问题,我无法获取它的位置。

Errors: 错误:
Notice : Undefined index: username in ... 注意 :未定义索引:...中的用户名
Notice : Undefined index: password in ... 注意 :未定义的索引:密码在...

<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>

Thanks! 谢谢!

You need to put the name for your inputs: 您需要输入名称:

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

That should fix the problem! 那应该解决问题!

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

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