-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
102 lines (69 loc) · 3.53 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
<?php
$result="";
if (isset($_POST["submit"])) {
if (!$_POST["name"]) {
$error="<br />Please enter your name";
}
if (!$_POST["email"]) {
$error.="<br />Please enter your email";
}
if (!$_POST["comment"]) {
$error.="<br />Please enter your comment";
}
if ($_POST["email"] AND !filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
$error.="<br />Please enter a valid email adress";
}
if (isset($error)){
$result='<div class="alert aviso"><strong>There were error(s) in your form:</strong><i>'.$error.'</i></div>';
} else {
if (mail("[email protected]", "Comment from website!", "Name: ".$_POST['name']."
Email: ".$_POST['email']."
Comment: ".$_POST['comment'])) {
/*$result='<div class="aviso_success">Form submitted</div>';*/
$result='<div class="aviso_success">Thank you! I\'ll get in touch.</div>';
$success = true;
} else {
$result='<div class="alert aviso"><strong>There was an error sending your message. Please try again later.</strong></div>';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Contact</title>
<meta name="description" content="Una guía interactiva de primeros pasos para Brackets.">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<div class="container">
<div class="rojo"></div>
<div class="azul"></div>
<div class="verde"></div>
<div class="amarillo"></div>
<main>
<header>
<h1>My Email Form</h1>
<?php
echo $result; ?>
<p>Please get in touch. I'll back to you as soon as I can</p>
</header><!-- /header -->
<form method="post">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Enter your Name" value="<?php if (isset($_POST['name'])){ echo $name = $_POST['name'];} ?>" >
<label for="email">Email</label>
<input type="email" name="email" placeholder="Enter your Email" value="<?php if(isset($_POST['email'])){ echo $email = $_POST['email'];} ?>">
<label for="comment">Comments</label>
<textarea name="comment" placeholder="Enter your Comments"><?php if(isset($_POST['comment'])){ echo $comment = $_POST['comment']; } ?></textarea>
<input type="submit" name="submit" value="Submint">
</form>
<!-- if (!empty($_POST["name"]) && !$success) { echo $_POST["name"]; } -->
</main>
</div>
</body>
</html>