将POST数据输入MySQL表无法正常工作

时间:2017-04-06 20:51:29

标签: php html mysql cloud9

在将输入字段中的用户数据输入MySQL表时遇到一些问题。这是代码。任何帮助表示赞赏。

<form action="login.php" method="post">
                    First Name: <input type="text" name="name" /> <br />
                    Last Name: <input type="text" name="lName" /> <br />
                    Email: <input type="email" name="email" /> <br />
                    Username: <input type="text" name="uName" /> <br />
                    Password: <input type="password" name="pw" /> <br />
                        <input type="submit" name="register" />
            </form>
            <br>
            <form action="login.php">
               Already have an account?
                    <input type="submit" value="Login Here" />
            </form>
    </div>
    <?php 
    if (isset($_POST["register"])){
     $name = $_POST["name"];
     $lName = $_POST["lName"];
     $email = $_POST["email"];
     $uName = $_POST["uName"];
     $pw = $_POST["pw"];

     $db = new mysqli($servername, $username, $password, $database, $dbport);
     $sql = "INSERT INTO users VALUES (null, $name, $lname, $email, $uName, $pw, null)";

     $result = mysqli_query($db, $sql);
    }
    ?>

0 个答案:

没有答案