<?php



//header('Access-Control-Allow-Origin: http://coopervision.com.hk');

header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');



$servername = "apps.webpuppies.com.sg";

$username = "webpuppi_master";

$password = "internal123";

$dbname = "webpuppi_cv";



// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

$conn->set_charset('utf8mb4');

// Check connection

if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

} 



$sqlin = "SELECT * FROM hkclariti_signups WHERE id='477'";

$result1 =  $conn->query($sqlin);

$user = [];

if ($result1->num_rows > 0) {

    // output data of each row

    while($row = $result1->fetch_assoc()) {

       $user = $row;

    }

    

}



$sql = "SELECT * FROM hkclariti_outlets WHERE id='104'";

$result = $conn->query($sql);

$shop = [];

if ($result->num_rows > 0) {

    // output data of each row

    while($row = $result->fetch_assoc()) {

       $shop = $row;

    }

    

}



$name = $user['name'];

$couponid = strtoupper(substr(md5($user['email']), 0, 8));;

$product = $user['product'];

$shopname = $shop['name'];

$shopaddress = $shop['address'];

$shopcontact = $shop['telno'];



$to = $user['email'];

$subject = '=?UTF-8?B?' . base64_encode('感謝登記 clariti 1 day') . '?=';

$headers = "From: CooperVision Hong Kong <no-reply@coopervision.com>\r\n" .

                "Reply-To: no-reply@coopervision.com\r\n" .

                "MIME-Version: 1.0\r\n" .

                "Content-Type: text/html; charset=utf-8\r\n";



ob_start();

include 'edm.php'; //execute the file as php

$body = ob_get_clean();



//mail($to, $subject, $body, $headers);







//send email

/*

$sql = "SELECT * FROM hkclariti_outlets";

$result = $conn->query($sql);

$json = array();



if ($result->num_rows > 0) {

    // output data of each row

    while($row = $result->fetch_assoc()) {

       $json[] = $row;

    }

    echo json_encode($json);

} else {

    echo "0 results";

}



*/

$conn->close();