I am making a CRUD. I get stuck at the output of the create. When creating, I have to save the data in the output, which is entered in the html form, in 3 different tables. As I have the code now, the data is only stored in the table lid and not in email and telefoonnummer. the primary key in the 3 tables is Lidnummer.
<?php
require_once 'login.php';
$conn = new mysqli ($hn, $un, $pw, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submit']))
{
$Naam = $_POST['Naam'];
$Voornaam = $_POST['Voornaam'];
$Huisnummer = $_POST['Huisnummer'];
$Postcode = $_POST['Postcode'];
$Telefoonnummer = $_POST['Telefoonnummer'];
$Emailadres = $_POST['Emailadres'];
$query = "INSERT INTO lid (Naam, Voornaam, Postcode, Huisnummer) VALUES ('$Naam', '$Voornaam','$Postcode','$Huisnummer')";
$query1 = "INSERT INTO email(Emailadres) VALUES ('$Emailadres')";
$query2 = "INSERT INTO telefoonnummers(Telefoonnummer) VALUES ('$Telefoonnummer')";
mysqli_query($conn, $query);
mysqli_query($conn, $query1);
mysqli_query($conn, $query2);
$result = mysqli_multi_query($conn, $query);
if($result)
{
echo "Data Inserted Successfully!";
}
else {
echo "Data Not Inserted!. Error: " . $query . "" . mysqli_error($conn);
}
}
?>