This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db-mail.php
119 lines (90 loc) · 4.37 KB
/
db-mail.php
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
//Required files to send mail
require '/lib/PHPMailer/class.phpmailer.php';
require "/lib/PHPMailer/PHPMailerAutoload.php";
//confirm User mail
function AlertUser(){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'xxxxxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
$mail->From = '[email protected]';
$mail->FromName = 'OneCloud Consulting';
$mail->addAddress($_POST['email']);
$mail->isHTML(true);
$mail->Subject = '[OpenStack - Webinar] OneCloud Consulting: Registration confirmed!';
$mail->Body = 'Hello'.' '.$_POST['firstname'].' '.$_POST['lastname'].','."<br/>"."<br/>"."<b>Webinar Event scheduled on</b> :" .$_POST['timezone']."<br/>"."<br/>"."<img src=\"cid:logoimg\"/>"."<br/>"."<br/>"."<br/>"."<br/>".'Regards,'."<br/>".'<b>OneCloud Consulting Team</b>';
$mail->AddEmbeddedImage("images/thank-you.png", 'logoimg');
if(!$mail->send()) {
echo 'Your registration failed, Please try again later!';
//echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Your registration has been successful! Your confirmation email is on its way, Please take a look.';
header("Location: http://xx.xx.xx.xx:9999/thank-you.html");
}
}
AlertUser();
function AlertAdmin(){
$email = new PHPMailer;
$email->isSMTP();
$email->Host = 'smtp.gmail.com';
$email->SMTPAuth = true;
$email->Username = '[email protected]';
$email->Password = 'xxxxx';
$email->SMTPSecure = 'tls';
$email->Port = 25;
$email->From = '[email protected]';
$email->FromName = 'OneCloud Consulting';
$email->addAddress('[email protected]');
$email->isHTML(true);
$email->Subject = '[OpenStack - Webinar] OneCloud Consulting: New Registration confirmed!';
$email->Body = 'Hi Admin,'."<br/>".'A new user registered successfully for an Virtual Event introducing OpenStack Webinar!'."<br/>"."<br/>".'<b>FirstName</b> :'.$_POST['firstname']."<br/>".'<b>LastName</b> :'.$_POST['lastname'].'<br/>'.'<b>Email Address</b> :'.$_POST['email']."<br/>".'<b>Company</b> :'.$_POST['company']."<br/>".'<b>JobTitle</b> :'.$_POST['jobtitle']."<br/>".'<b>Country</b> :'.$_POST['country']."<br/>".'<b>State</b> :'.$_POST['state']."<br/>".'<b>Phone Number</b> :'.$_POST['mobile']."<br/>".'<b>TimeZone</b> :'.$_POST['timezone']."<br/>"."<br/>"."<br/>"."<br/>".'Regards,'."<br/>".'OneCloud Consulting Team';
if(!$email->send()) {
echo 'New User registration failed, due to some technical error!';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'A User has been registered successfully!';
}
}
AlertAdmin();
function RegisterUserToDatabase(){
$servername = "localhost";
$username = "root";
$password = "pass";
$dbname = "webinar";
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$company = $_POST['company'];
$jobtitle = $_POST['jobtitle'];
$country = $_POST['country'];
$state = $_POST['state'];
$mobile = $_POST['mobile'];
$timezone = $_POST['timezone'];
$identity = $_POST['identity'];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "INSERT INTO webinar_users (firstname,lastname,email,company,jobtitle,country,state,phone_number,timezone,identity) VALUES('$firstname', '$lastname', '$email', '$company', '$jobtitle', '$country', '$state', '$mobile', '$timezone', '$identity')";
if (mysqli_query($conn, $sql)) {
$success = "New user record is created successfully ";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql1= "INSERT INTO users_list (firstname, lastname, email) VALUES ('$firstname', '$lastname', '$email')";
if (mysqli_query($conn, $sql1)) {
$success = "New user record is created successfully ";
} else {
echo "Error: " . $sql1 . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
}
RegisterUserToDatabase()
?>