<?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 to create table
  $sql = "CREATE TABLE SMSContacts (
  id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  clientID VARCHAR(30) NOT NULL,
  firstname VARCHAR(30) NOT NULL,
  lastname VARCHAR(30) NOT NULL,
  initials VARCHAR(10),
  type VARCHAR(20),
  email VARCHAR(50),
  phone VARCHAR(20),
  notes VARCHAR(100),
  localdateTime VARCHAR(50),
  reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  )";

  // use exec() because no results are returned
  $conn->exec($sql);
  echo "Table Contacts created successfully";
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}

$conn = null;

?>
