Search code examples
phpmysqlregistrationinsert-into

mysql_query("INSERT INTO... is not working


I'm trying to create a registration page. The page is successfully connected to phpMyAdmin database but it does not echo anything when i click the register button.

<html>
<head>
</head>

<body>

<?php
INCLUDE "connect.php";
INCLUDE "functions.php";
INCLUDE "titlebar.php";
?>

            <div id="loginform">    
            <h1>Register</h1>

            <form name="Register" action="register.php" method="post">
            <?php
            if(isset($POST["submit"])){
                    $username = $_POST["username"];
                    $password = md5 ($_POST["password"]);
                    if(empty($username) or empty($password)){
                            echo "<p>Fields Empty!</p>";
                    } else {
                            mysql_query("INSERT INTO login VALUES('',$username','$password','2','')");
                            echo "<p>Successfully Registered!</p>";
                    }
            }
            ?>
                <p>     
                    <label for="username">Username: </label>
                    <input type="text" name="username" id="username"/></p><p>

                    <label for="password">Password: </label>
                    <input type="password" name="password" id="password"/></p><p>
                    <input type="submit" name="submit" value="Register" />
                </p>
            </form>
            </div>
</body>

Solution

  • The problem is with the post method. use $_POST instead of $POST