-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
93 lines (78 loc) · 2.73 KB
/
index.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
<?php
$status = '';
if ( isset($_POST['submit']) ) {
if ( $_SERVER["REQUEST_METHOD"] == "POST" ) {
if ( empty($_POST["name"]) ) {
$nameErr = "Name is required";
} else {
$fullname = test_input($_POST["name"]);
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = '[email protected]';
$mail_subject = 'Message from Website';
$email_body = "Message from Contact Us Page of the Website: <br>";
$email_body .= "<b>From:</b> {$fullname} <br>";
$email_body .= "<b>Subject:</b> {$subject} <br>";
$email_body .= "<b>Message:</b><br>" . nl2br(strip_tags($message));
$header = "From: {$email}\r\nContent-Type: text/html;";
$send_mail_result = mail($to, $mail_subject, $email_body, $header);
if ( $send_mail_result ) {
$status = '<p class="success">Message Sent Successfully !</p>';
} else {
$status = '<p class="error">Message Was Not Sent.</p>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Us</title>
<link rel="stylesheet" href="css/stylesheet.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<div class="form-div">
<h3 class="title-h3"> Send Mail </h3>
<div class="div-main">
<form action="index.php" method="post">
<p class="label-p">
<label for="fullname">Full Name :</label>
<input type="text" name="fullname" id="fullname" required>
</p>
<p class="label-p">
<label for="email">Email :</label>
<input type="email" name="email" id="email" required>
</p>
<p class="label-p">
<label for="subject">Subject :</label>
<input type="text" name="subject" id="subject" required>
</p>
<p class="label-p">
<label for="message">Message : </label>
<textarea name="message" id="message" cols="30" rows="10" required></textarea>
</p>
<p class="label-p">
<button type="submit" name="submit" class="btn btn-outline-primary">Send Message</button>
</p>
<div class="message-alert">
<?php echo $status; ?>
</div>
</form>
</div>
</div>
</div>
</body>
</html>