I was trying to understand how signup forms work, came across this. Got stuck at passing Sql queries through prepare()
<?php include 'connectdb.php';
if(isset($_POST['username'])){
$username=$_POST['username'];
}
if (isset($_POST['password'])) {
$password=$_POST['password'];
}
if (isset($_POST['email'])) {
$email=$_POST['email'];
}
if (isset($_POST['firstname'])) {
$firstname=$_POST['firstname'];
}
if (isset($_POST['lastname'])) {
$lastname=$_POST['lastname'];
}
if(isset($_POST['birthday_day'])
&&isset($_POST['birthday_month'])
&&isset($_POST['birthday_year'])){
$dob = $_POST['birthday_year']."-".$_POST['birthday_month']."- ".$_POST['birthday_day'];
}
$sex = "F"; /*Temporarliy passing!*/
$sqlCombined = "INSERT INTO `login` (username, password) VALUES (?,?); INSERT INTO `userdata` (username,dob,firstname,lastname,email,sex) VALUES (?,?,?,?,?,?)";
$stmt = $db-> prepare($sqlCombined);
$stmt -> bind_param('ssssssss', $username,$password,$username,$dob,$firstname,$lastname,$email,$sex);
$stmt -> execute();
$stmt -> close(); header("location: login.php"); ?>
Error Log:
Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:\xampp\htdocs\puddleweb\signup.php:67 Stack trace: #0 {main} thrown in C:\xampp\htdocs\puddleweb\signup.php on line 67