<?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);
  $sql = "INSERT INTO MyContacts (firstname, lastname, email, phone)
  VALUES ('John', 'Doe', 'john@example.com', '1-888-555-1234')";
  // use exec() because no results are returned
  $conn->exec($sql);
  echo "New record created successfully";
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}

$conn = null;

?>
