-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendData.php
More file actions
94 lines (71 loc) · 2.44 KB
/
sendData.php
File metadata and controls
94 lines (71 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
ini_set("include_path", '/pathTo/yourPHPfolder/php:' . ini_get("include_path") );
$siteURL = "SITE URL THAT THE IMAGE IS BEING APPENDED";
$servername = "localhost";
$port = "3306";
$dbuser = "PROVIDE YOUR DB USERNAME";
$userpw = "PROVIDE YOUR DB PASSWORD";
$dbName = "PROVIDE YOUR DB NAME";
$datetime = new DateTime();
$timezone = new DateTimeZone('Asia/Kuala_Lumpur');
$datetime->setTimezone($timezone);
$USERDATA = $_POST["userData2"];
$obj = json_decode($USERDATA);
$EventID = $obj->EventID;
$Name = $obj->FullName;
$Contact = $obj->MobileNo;
$Email = $obj->EmailAddr;
$PicturePath = $obj->ExtraData;
$DTime = $datetime->format('Y-m-d H:i:s');
$conn = new mysqli($servername, $dbuser, $userpw, $dbName);
if(!$conn)
{
die("Connection Failed: ". mysqli_connect_error());
echo "failed lol";
}
$sql = "INSERT INTO imVBoothDB_users (EVENTID,NAME,EMAILADDR,PHONENUM,EXTRADATA,datetime)
VALUES ('".$EventID."','".$Name."','".$Email."','".$Contact."', '".$PicturePath."', '".$DTime."')";
if(mysqli_query($conn, $sql))
{
echo "New Record Created Successfully";
}
else
{
echo "Error";
}
$DTime = $datetime->format('Y-m-d_H-i-s');
$b64 = $PicturePath;
$bin = base64_decode($b64);
$im = imageCreateFromString($bin);
if (!im) {
die('Base64 value is not a valid image');
}
$img_file = "./imageUploads/images/vBooth-$DTime.jpg";
imagejpeg($im, $img_file, 100);
imagedestroy($im);
$hyperlink_file = $siteURL."imageUploads/images/vBooth-$DTime.jpg";
echo "\n".$hyperlink_file."\n";
include('Mail.php');
include('Mail/mime.php');
$recipients = $Email;
$headers['From'] = 'PROVIDE THE EMAIL THAT IS UNDER YOUR DOMAIN';
$headers['To'] = $Email;
$headers['Subject'] = 'Thanks for playing! ';
$crlf = "\r\n";
$mime = new Mail_mime($crlf);
$body = "Here's the most beautiful, you: ";
$message = "<b>Here's the most beautiful, you: </b>";
$message .= "<a href='$hyperlink_file'>click here to view</a><br>";
$message .= "<p>with love, <br>BRAND NAME</p>";
$mime->setTXTBody($body);
$mime->setHTMLBody($message);
$body = $mime->get();
$headers = $mime->headers($headers);
$params['sendmail_path'] = '/usr/lib/sendmail';
$mail_object =& Mail::factory('sendmail', $params);
$mail_object->send($recipients, $headers, $body);
mysqli_close($conn);
header('Content-Type:application/json');
$arr = ["path" => '123'];
echo json_encode($arr);
?>