-1

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!

1 Answers1

2

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!