I'm trying to insert $_POST data that I have stored in variables to be stored in my database. The connection to the database is fine, however, I'm getting the following error
Error: INSERT INTO users (user_id, password, bankpin, auth, ip) VALUES ('sadasd', 'asdasd', '3434', '324234', '76.68.85.19')
So far I've tried inserting single and double quotes in various places such as around the table name and fields, however, I receive the same error.
Here is my php code:
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO users (user_id, password, bankpin, auth, ip) VALUES ('$user_id', '$password', '$bankpin', '$auth', '$ip')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();