-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
76 lines (71 loc) · 3.01 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
/*
Author : Raj Kinkhabwala
Version = 1.0
*/
<?php
// Message vars
$msg = '';
$msgClass = '';
// If Form Gets Submitted
if(filter_has_var(INPUT_POST, 'submit')){
// Data gets Passed from here
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$message = htmlspecialchars($_POST['message']);
if(!empty($name) && !empty($email) && !empty($message)){
// Passed
//check email
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
$msg = 'Please Enter the valid email';
$msgClass = 'alert-danger';
}
}
else{
$msg = 'Please fill all the fields';
$msgClass = 'alert-danger';
}
}
else{
// Passed
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://bootswatch.com/4/lux/bootstrap.min.css">
<title>Contact Us Page</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#">Contact US :)</a>
</nav>
<?php if($msg != ''): ?>
<div class="alert alert-dismissible <?php echo $msgClass; ?>">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><?php echo $msg; ?></strong>
</div>
<?php endif; ?>
<div class="container">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<div class="form-group">
<label for="email">Email Address</label>
<input type="text" class="form-control" name="email" id="email" placeholder="Enter your Email" value="<?php echo isset($_POST['email']) ? $email : ''; ?>">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter your Name" value="<?php echo isset($_POST['name']) ? $name : ''; ?>" >
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea name="message" id="message" class="form-control" placeholder="Enter the Message Here!"><?php echo isset($_POST['message']) ? $message : ''; ?></textarea>
</div>
<br>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</body>
</html>