-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
116 lines (108 loc) · 2.73 KB
/
contact.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
<?php
session_start();
if(!isset($_SESSION["name"]))
{?>
<script>
location.replace("login.php");
</script><?php
}
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$name=trim($_POST["name"]);
$email=trim($_POST["email"]);
$message=trim($_POST["message"]);
if($name == "" OR $email == "" OR $message == "")
{
$errormessage= "You cannot leave Name,Email or Message empty.";
}
$mailbody="";
$mailbody=$mailbody.$name.'<br>';
$mailbody=$mailbody.$email.'<br>';
$mailbody=$mailbody.$message;
include("phpmailer/class.smtp.php");
require_once 'phpmailer/PHPMailerAutoload.php';
$mail=new PHPMailer;
if(!isset($errormessage)){
if(!$mail->ValidateAddress($email))
{
$errormessage= "Please enter your valid mail address";
}}
if(!isset($errormessage)){
$mail->IsSmtp();
$mail->SMTPDebug=1;
$mail->SMTPAuth=true;
$mail->SMTPSecure='ssl';
$mail->Host="ssl://smtp.gmail.com";
$mail->Port=465;
$mail->IsHTML(true);
$mail->Username="[email protected]";
$mail->Password="sonyxperia1";
$mail->SetFrom($email);
$mail->Subject="Contact";
$mail->Body=$mailbody;
$mail->AddAddress("[email protected]");
if($mail->Send())
{
header("location: contact-thanks.php");
exit;
}
else
{
$errormessage= "OOPs!!!!! SomeThing went wrong. Please after some time.";
}
}
}
?>
<?php
$header="Contact Mike";
$section="contact";
include('header.php');?>
<html>
<?php $message="I’d love to hear from you! Complete the form to send me an email.";?>
<br><br>
<div class="format">
<h1 class="text-center">CONTACT</h1>
<p class="text-center"><?php
if(!isset($errormessage)) echo $message;
else{ ?><h4 class="error text-center"><?php echo "*".$errormessage;}?>
</h4></p><br><br>
<form method="post" action="contact.php">
<table>
<tr>
<th>
<label for="name">Name</label>
</th>
<td>
<input type="text" name="name" id="name" required>
<td>
</tr>
<tr>
<th>
<label for="email">Email</label>
</th>
<td>
<input type="text" name="email" id="email" required>
</td>
</tr>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea name="message" id="message"></textarea required>
</td>
</tr>
<tr style="display:none;">
<th>
<label for="add">Address</label>
</th>
<td>
<input type="text" name="Address" id="add"></input>
</td>
</tr>
</table>
<br><button class="btn b">SUBMIT</button>
</form>
</div>
</html>
<?php include('footer.php');?>