将表单数据插入数据库[关闭]

This is starting to wind me up.. I've started building the PHP for the register page but none of the inputted data is inserting into the database.

I know the inputs aren't secure, it's just completely basic as i stripped it down completely and now this isn't even working. I'm not getting any errors in my log, and there is a connection to the database.

All the data from the form is echoing out, just to make sure it recognises the input fields, but it's really starting to wind me up... And also, I'm not using a later version of PHP, reason why I'm not using mysqli_query instead of mysql_query.

session_start();
include_once "settings/conf.php";
  if(isset($_POST['join'])){
    $username=$_POST['username'];
    $email=$_POST['email'];
    $password=$_POST['password'];
    $date=date("Y-m-d H:i:s");
mysql_query("INSERT INTO users (username, password, email, joinData, contributor)
VALUES ('$username', '$password','$email','$date'0)");
echo 'Ok.';
}

Please, can somebody help me!

Much appreciated!

Then, in your query it looks like (at the position of the $date variable) you missed a comma, this is required to separate those 5 values. This probably solves the issue.

mysql_query("INSERT INTO users (username, password, email, joinData, contributor)
VALUES ('$username', '$password','$email','$date',0)");

If it still won't work:

  • Have you tried to print those values from the POST methods on the page to see if they even come through?
  • Then, are you sure you've set the method to POST in your form?
mysql_query("INSERT INTO users (username, password, email, joinData, contributor) VALUES ('$username', '$password','$email','$date'0)");

You are missing here a comma before the zero:

mysql_query("INSERT INTO users (username, password, email, joinData, contributor) VALUES ('$username', '$password','$email','$date', 0)");
THERE -----------------------------------------------------------------------------------------------------------------------------^

you missing a comma in between date and 0

mysql_query("INSERT INTO users (username, password, email, joinData, contributor)
VALUES ('$username', '$password','$email','$date',0)");
echo 'Ok.';
}

You are filtering/sanitizing all your $_POST data before entering into your DB?