<?php

require('config.php');

function randHash($len=32)
{
	return substr(md5(openssl_random_pseudo_bytes(20)),-$len);
}

$linkID = new PDO('mysql:host='.Config::DB_HOST.';dbname='.Config::DB_NAME, Config::DB_USERNAME, Config::DB_PASSWORD);
$linkID->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Setting ERRMODE


$company_name = $linkID->query("SELECT * FROM ea_settings WHERE ea_settings.id=14")->fetchAll(PDO::FETCH_ASSOC);
$company_email = $linkID->query("SELECT * FROM ea_settings WHERE ea_settings.id=15")->fetchAll(PDO::FETCH_ASSOC);
$company_link = $linkID->query("SELECT * FROM ea_settings WHERE ea_settings.id=16")->fetchAll(PDO::FETCH_ASSOC);

$waitlistfirstname = $_POST['waitlist-firstname']; 
$waitlistlastname = $_POST['waitlist-lastname']; 
$waitlistphonenumber = $_POST['waitlist-phonenumber']; 
$waitlistemail = $_POST['waitlist-email']; 
$waitlistnotes = $_POST['waitlist-notes']; 
$waitlistpharmacynotes = $_POST['waitlist-pharmacy-notes']; 
$waitlistservice = $_POST['waitlist-service']; 
$waitlisthash = $_POST['waitlisthash']; 
$waitlistid = $_POST['waitlistid']; 

$servicewhich = $linkID->query("SELECT * FROM ea_services WHERE ea_services.id=".$waitlistservice)->fetchAll(PDO::FETCH_ASSOC);
//echo $servicewhich[0]['name'];
$data = [

    'id'=>$waitlistid, 
    'hash'=> $waitlisthash,
];


$sql = "DELETE FROM waitlist WHERE hash=:hash AND id=:id";
//echo $sql; 
$stmt= $linkID->prepare($sql);
$stmt->execute($data);

 

echo 'Your record has been successfully deleted. ';




?>