This question already has an answer here:
Ok i have updated to a prepared statement and i still cannot get the dob to work any thoughts?
<?php
require ("func/insert.php");
if(isset($_POST['Submit'])){
//prepare and bind
$stmt = $con->prepare("INSERT INTO users (first_name, last_name, email, password, date_of_birth, gender) VALUES (?,?,?,?,?,?)");
$stmt->bind_param("ssssss", $first_name, $last_name, $email, $StorePassword, $dob, $gender);
//set parameters and execute
$first_name = isset($_POST['first_name']) ? $_POST['first_name'] : ' ';
$last_name = isset($_POST['last_name']) ? $_POST['last_name'] : ' ';
$email = isset($_POST['email']) ? $_POST['email'] : ' ';
$password = isset($_POST['password']) ? $_POST['password'] : ' ';
$dob = isset($_POST['date_of_birth']) ? $_POST['year. month. day'] : ' ';
$gender = isset($_POST['gender']) ? $_POST['gender'] : ' ';
$StorePassword= password_hash($password, PASSWORD_BCRYPT, array('cost' => 10));
$stmt->execute();
$stmt->close();
}
?>
</div>
Your idea of running a query from PHP is wrong. You should be using prepared statements. For more details follow the link attached to your question now.
PS. DO NOT follow outdated and erroneous tutorials from youtube. Follow the answer I linked to.
To get your date
$dob = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
Next time, if you get stuck with some particular variable, echo it out and see, does it meet your expectations or not. If not - ask a question regarding this particular variable only, without any other interfering code.