-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontact-us.php
73 lines (57 loc) · 2.23 KB
/
contact-us.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-master/src/PHPMailer.php';
require 'PHPMailer-master/src/SMTP.php';
require 'PHPMailer-master/src/Exception.php';
$host = "localhost";
$dbusername = "id14446204_nishritha_admin";
$dbpassword = "m7ZN9GrX9_YaBnT";
$dbname = "id14446204_nishritha_foundation";
$conn = new mysqli($host,$dbusername,$dbpassword,$dbname);
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$msg=$_POST['msg'];
if(mysqli_connect_error()){
die('Connect error'.mysqli_connect_errno().')'.mysqli_connect_error());
}
else{
$sql = "INSERT INTO contact (name,email,phone,msg) values ('$name','$email','$phone','$msg')";
$conn->query($sql);
}
$conn->close();
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]'; //your gmail ID username
$mail->Password = 'wgmgghpwkwtqfznr'; //your gmail password
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->CharSet = "UTF-8";
$mail->setFrom('[email protected]', 'Updates from contact form'); //first parameter your username
$mail->addAddress('[email protected]');
$mail->isHTML(true);
$mail->Subject = 'Hey, someone just filled contact form';
//Changes
$mail->Body = "<!DOCTYPE html>
<head>
<title>
Nishritha foundation
</title>
</head>
<body>
<p> Name: $name</p>
<p>Email-ID: $email</p>
<p>Phone number: $phone</p>
<p>Message: $msg</p>
</body>
</html>";
$mail->send();
header("Location:home.html#contactus");
}
?>