-
Notifications
You must be signed in to change notification settings - Fork 2
/
email2.php
50 lines (43 loc) · 1.36 KB
/
email2.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
<?php
include('connection.php');
$query1 = "SELECT * FROM patient where email = '" . $_POST["email"] . "'";
$result = mysqli_query($conn,$query1);
$count = mysqli_num_rows($result);
//echo "num row executed".$count."\n";
if($count==0) {
$query = "INSERT INTO patient (first_name, last_name, email, gender,address,phone) VALUES('" . $_POST["first_name"] . "', '" . $_POST["last_name"] . "', '" . $_POST["email"] . "', '" . $_POST["gender"] . "', '" . $_POST["address"] . "', " . $_POST["mobile_no"] . ")";
$current_id = mysqli_query($conn,$query);
//echo $query."\n";
if(!empty($current_id)) {
require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465 ; //587;
$mail->isHTML();
$mail->Username = 'sanurag616@gmail.com';
$mail->Password = '10011999';
$mail->SetFrom("No rply");
$mail->Subject = 'Registration';
$mail->Body = 'You are registered to our system';
$add = $_POST["email"];
$mail->AddAddress($add);
try {
$mail->send();
echo "send";
}
catch (Exception $ex) {
echo $msg = $ex->getMessage();
}
}
else
{
echo "mail not executed";
}
} else {
$message = "User Email is already in use.";
}
?>