Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //insert.php
- //This page handles the inserting into the database of the new contact
- require_once('db.inc.php');
- $sql = "INSERT INTO mad9023_contacts (contact_first,
- contact_email) VALUES (:first, :last, :email)";
- $query = $pdo->prepare($sql);
- $values = [
- ':first' => $_SERVER['HTTP_CONTACT_FIRST'],
- ':last' => $_SERVER['HTTP_CONTACT_LAST'],
- ':email' => $_SERVER['HTTP_CONTACT_EMAIL']
- ];
- $stmt= $query->execute($values);
- $result = $pdo->query("SELECT * FROM `mad9023_contacts` WHERE contact_id= LAST_INSERT_ID();");
- $errorInfo = $pdo->errorInfo();
- if (isset($errorInfo[2])){
- echo $errorInfo[2];
- exit;
- }
- //use one of these based on the parameters
- if (isset($_GET['type']) && $_GET['type'] == 'json'){
- header("Content-Type: application/json");
- echo json_encode(["success" => (bool) $result,"affected" => (int) $reult]);
- }
- header("Content-Type: text/xml");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement