-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact-us.php
124 lines (80 loc) · 3.08 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
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
119
120
121
122
123
124
<?php
$success = NULL;
//Only Run This After A submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if($_POST["firstname"] == "" || $_POST["lastname"] == "" || $_POST["country"] == "" || $_POST["email"] == ""){
//Form Is missing required fields
$success = false;
} else {
$to = "[email protected]";
$subject = "Form Submission";
$txt =
"First Name: ". $_POST["firstname"] . "\n" .
"Last Name: ". $_POST["lastname"] . "\n" .
"Country: ". $_POST["country"] . "\n" .
"Email: ". $_POST["email"] . "\n" .
"Phone: ". $_POST["phone"] . "\n" .
"Timezone: ". $_POST["timezone"] . "\n" .
"Comments: ". $_POST["comments"];
$headers = "From: [email protected]";
mail($to,$subject,$txt,$headers);
$success = true;
}
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" charset="UTF-8">
<link rel="icon" href="/CS12/Images/favicon.ico">
<link rel="stylesheet" href="/CS12/Styles/style.css">
<title>Mantas - Contact Us</title>
</head>
<body>
<?php
$path = $_SERVER['DOCUMENT_ROOT'] . "/CS12/header.php";
include_once($path);
?>
<div class="content">
<div class="content-item">
<?php if(!isset($success)){ ?>
<h1>Contact Us</h1>
<p> Feel free to leave us any comments or concerns </p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="text" name="firstname" placeholder="Joe">
<input type="text" name="lastname" placeholder="Shmoe">
<input type="text" name="country" placeholder="USA">
<input type="text" name="email" placeholder="[email protected]">
<input type="text" name="phone" placeholder="1(234)567-8910">
<input type="text" name="timezone" placeholder="PST">
<input type="text" name="comments" placeholder="Comments...">
<br><br>
<input type="submit" value="Submit">
</form>
<?php } elseif($success){ ?>
<h1>Successfully Submitted!</h1>
<p> yay </p>
<?php } elseif(!$success) { ?>
<h1>Contact Us</h1>
<p> Feel free to leave us any comments or concerns </p>
<p class="error"> First name last name and email are required. </p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="text" name="firstname" placeholder="Joe">
<input type="text" name="lastname" placeholder="Shmoe">
<input type="text" name="country" placeholder="USA">
<input type="text" name="email" placeholder="[email protected]">
<input type="text" name="phone" placeholder="1(234)567-8910">
<input type="text" name="timezone" placeholder="PST">
<input type="text" name="comments" placeholder="Comments...">
<br><br>
<input type="submit" value="Submit">
</form>
<?php } ?>
</div>
</div>
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/CS12/footer.html";
include_once($path);
?>
</body>
</html>