-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·118 lines (88 loc) · 3.13 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
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
<?php
// ==============================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$user = filter_var($_POST['username'],FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_NUMBER_INT);
$msg = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
$errors = array();
if (strlen($user) < 3) {
$errors[] = 'Your Username Must Be lrger Than 3 character';
# code...
}
$headers = 'from: '. $email . '\r\n';
$myEmail = '0ahmedibrahem@gmail.com';
$subject = 'contact Form';
if (strlen($msg) < 3) {
$errors[] = 'Your message Must Be lrger Than 3 character';
# code...
}
if (empty($errors)){
mail($myEmail, $subject, $msg, $headers);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Login Form</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/styles.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,700,900,900i" rel="stylesheet">
</head>
<body>
<!-- simple form -->
<div class="container">
<h2 class="text-center">Contact Me</h2>
<div class="erorrs">
<?php
if(! empty($errors)){
foreach ($errors as $error) { ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Warning!</strong>
<?php
# code...
echo $error . "<br />";
}
}
?>
</div>
</div>
<form class="my-form" action="<?php echo $_SERVER['PHP_SELF']?>" method="POST">
<input class="form-control username"
type="text" name="username"
value="<?php if(isset($errors)){if(isset($user)){echo $user;}} ?>"
placeholder="Type Your username">
<i class="fa fa-user fa-fw" aria-hidden="true"></i>
<div class="alert alert-warning custom-alert">
username Must Be longer then 3 chracter
</div>
<input class="email form-control"
type="email" name="email"
placeholder="please type your vaild email">
<i class="fa fa-envelope-open fa-fw" aria-hidden="true"></i>
<div class="alert alert-warning custom-alert-email">
This is wrong email
</div>
<input class="phone form-control"
type="text" name="phone"
placeholder="type your number phone">
<i class="fa fa-phone fa-fw" aria-hidden="true"></i>
<div class="alert alert-warning custom-alert-phone">
This is wrong phone
</div>
<textarea class="form-control" placeholder="Write Your Message" name="message"></textarea>
<input class="btn btn-primary btn-block" type="submit" name="buttun" value="Send Your message">
<i class="fa fa-paper-plane plane" aria-hidden="true"></i>
</form>
</div>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>