<?php
session_start();
require_once "main.php";
ini_set('display_errors', 1);
error_reporting(E_ALL);
global $defaultHomeLink;
$tsi = 'No Data';
function console_log($output, $with_script_tags = true) {
    $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . 
');';
    if ($with_script_tags) {
        $js_code = '<script>' . $js_code . '</script>';
    }
    echo $js_code;
}
    $t1 = $_GET['dtm'];
    try {
        $sql = 'Select * from django.attendees_attendee where id="'.$t1.'";';
    $st = $db->prepare($sql);
    $st->execute();
    $result = $st->fetchAll();
    } catch (Exception $e) {
    console_log("something went wrong, caught yah! n");
} finally {
    console_log("this part is always executed n");
}
    try {
    $sql = 'Select value from django.attendeefields_attendeeoptionvalue where attendee_id="'.$t1.'" and option_id=7;';
    $st = $db->prepare($sql);
    $st->execute();
    $result1 = $st->fetchAll();
    } catch (Exception $e) {
    console_log("1something went wrong, caught yah! n");
} finally {
    console_log("1this part is always executed n");
}
    $sql = 'Insert into datam Values(null,?,?,?,?,?,?,?,?,?,?,?)';
    $st = $db1->prepare($sql);
  $st ->bindParam(1,$_SESSION['email']);
  $st ->bindParam(2,$result[0]['fname']);
  $st ->bindParam(3,$result[0]['lname']);
  $st ->bindParam(4,$result[0]['address']);
  $st ->bindParam(5,$result[0]['city']);
  $st ->bindParam(6,$result[0]['state']);
  $st ->bindParam(7,$result[0]['zipcode']);
  $st ->bindParam(8,$result[0]['phone']);
  $st ->bindParam(9,$result[0]['fax']);
  $st ->bindParam(10,$result[0]['email']);
  if (@$result1[0]<>"") {
      $st ->bindParam(11,$result1[0]['value']);
  } else {
      $st ->bindParam(11,$tsi);
  }
  $st->execute();
return true;
?>