<?php
## using POD so it works on other databases

## open connection to the database
$servername = "localhost";
$username = "tostonc_zx3";
$password = "A1s2d3f4!@#";
$dbname = "tostonc_zx3_test";


try {
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  // begin the transaction
  $conn->beginTransaction();
  // our SQL statements
  $conn->exec("INSERT INTO MyContacts (firstname, lastname, email, phone)
  VALUES ('John', 'Doe', 'john@example.com', '1-444-123-1234')");
  $conn->exec("INSERT INTO MyContacts (firstname, lastname, email, phone)
  VALUES ('Mary', 'Moe', 'mary@example.com', '0-321-333-55555')");
  $conn->exec("INSERT INTO MyContacts (firstname, lastname, email, phone)
  VALUES ('Julie', 'Dooley', 'julie@example.com', '1-222-444-6543')");

  // commit the transaction
  $conn->commit();
  echo "New records created successfully";
} catch(PDOException $e) {
  // roll back the transaction if something failed
  $conn->rollback();
  echo "Error: " . $e->getMessage();
}

$conn = null;

?>
