dongpan9760 2013-02-28 02:10
浏览 13
已采纳

PHP MySQL代码出错

I seem to having trouble with some of my PHP. It takes data from an HTML page and then adds it to a MySQL database, but the information does not appear.

<?php

    // Variables
    $email = $_POST["email"]; 
    $username = $_POST["username"]; 
    $password = $_POST["password"]; 
    $passwordconfirmation = $_POST["passwordconfirmation"];

    // Failure
    if ($password !== $passwordconfirmation)
    { 
       echo "The password fields do not match. Please enter your password again."; 
    } 

    // Success
    else
    {
    $connection = mysqli_connect("*****.com", "*****", "*****", "charlesfriessdatabase"); // Connect

     // Error Message
    if (!$connection)
    {
        die ("Error"); 
    }

    mysqli_query("INSERT INTO accounts (email, username, password) VALUES ($email, $username, $password)"); // Inserter

    mysqli_close($connection); // Connection Closer

    echo "You have successfully signed up! Please check your email to confirm your account."; // Success Message
}

?>
  • 写回答

4条回答 默认 最新

  • doudong8713 2013-02-28 02:21
    关注

    In the variables you need to put the ' Try Add this char and let us know.

    This is how supposed to be:

    mysqli_query("INSERT INTO accounts (email, username, password) VALUES ('$email', '$username', '$password')");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?