Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "usbw";
- $dbname = "persons";
- // CREATE A CONNECTION WITH THE DATABASE
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // ADDRESS APPEND - PREPARE SQL STATEMENT AND BIND PARAMS
- $stmt = $conn->prepare("INSERT INTO address (address_street, address_housenumber,
- address_zipcode, address_city, address_state)
- VALUES (?, ?, ?, ?, ?)");
- $stmt->bind_param("sssss", $straat, $huisnummer, $postcode, $stad, $provincie);
- $straat = htmlspecialchars($_POST[straat]);
- $huisnummer = htmlspecialchars($_POST[huisnummer]);
- $postcode = htmlspecialchars($_POST[postcode]);
- $stad = htmlspecialchars($_POST[stad]);
- $provincie = htmlspecialchars($_POST[provincie]);
- // EXECUTE STATEMENT
- $result = $stmt->execute();
- if ($result === FALSE) {
- die("Error: " . $stmt->error);
- }
- // CAPTURE LAST INSERTED address_id
- $last_id = $conn->insert_id;
- // PERSON APPEND - PREPARE SQL STATEMENT AND BIND PARAMS
- $stmt = $conn->prepare("INSERT INTO person (person_firstname, person_lastname,
- person_email, person_phonenumber,
- person_cv, person_address)
- VALUES (?, ?, ?, ?, ?, ?)");
- $stmt->bind_param("sssssi", $firstname, $lastname, $email, $telephone, $cv, $last_id);
- $firstname = htmlspecialchars($_POST[firstname]);
- $lastname = htmlspecialchars($_POST[lastname]);
- $email = htmlspecialchars($_POST[email]);
- $telephone = htmlspecialchars($_POST[telephone]);
- $cv = htmlspecialchars($_POST[cv]);
- // EXECUTE STATEMENT
- $result = $stmt->execute();
- if ($result === TRUE) {
- $URL="http://localhost:8080/Website/bedankt.php";
- header ("Location: $URL");
- } else {
- echo "Error: " . $stmt->error;
- }
- $stmt->close();
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement