i wanna insert form's data into different tables ,for exemple full name and email in patient table and appointment time in reserve table, the problem is patient table data inserts into it normally but reserve table remains empty ,i tried several times but nothing worked, so this is my try and if you cloud write a better code for me i would appreciate that
$sql= "INSERT INTO patient (fullname,phone,email)
VALUES ('$fullname','$phone','$email')";
$pid="SELECT idpatient FROM patient where email= '$email'" ;
$inst="INSERT INTO reserve ( apptime, patientID) VALUES ('$apptime','$pid' )";
if (mysqli_query($conn,$sql) ){
header ('Location:index.php#Reserve');
}else {
echo 'ERROR'. mysqli_error($conn);
}
if (mysqli_query($conn,$inst) ){
header ('Location:index.php#Reserve');
echo $apptime;
} else {
echo 'ERROR2'. mysqli_error($conn);
}
}