Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section id="contact">
- <h1 class="section-header">Contact Us Directly</h1>
- <h4 class="text-center">Have any quesitons not answered in the <span><a href="questions.php">Questions Page</a></span>.</h4>
- <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
- <label for="fname">First Name</label>
- <input type="text" id="fname" name="firstname" value="<?php $firstname ?>" placeholder="Your name.." tabindex="1" autofocus>
- <span class="error"><?php $firstname_error ?></span>
- <label for="lname">Last Name</label>
- <input type="text" id="lname" name="lastname" value="<?php $lastname ?>" placeholder="Your last name.." tabindex="2">
- <span class="error"><?php $lastname_error ?></span>
- <label for="email">Email</label>
- <input type="text" id="email" name="email" value="<?php $email ?>" placeholder="Your email.." tabindex="3">
- <span class="error"><?php $email_error ?></span>
- <label for="message">Message</label>
- <textarea id="subject" name="message" value="<?php $message ?>" placeholder="Write something.." style="height:200px" tabindex="4"> </textarea>
- <span class="error"><?php $message_error ?></span>
- <input type="submit" value="Submit" tabindex="5">
- <span class="success"><?php $success ?></span>
- </form>
- </section>
- <?php
- $firstname_error = $lastname_error = $email_error = $message_error = "";
- $firstname = $lastname = $email = $message = $success = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["firstname"])) {
- $firstname_error = "First name is required";
- } else {
- $firstname = test_input($_POST["firstname"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/",$firstname)) {
- $firstname_error = "Only letters and white space allowed";
- }
- }
- if (empty($_POST["lastname"])) {
- $lastname_error = "Last name is required";
- } else {
- $lastname = test_input($_POST["lastname"]);
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/",$lastname)) {
- $lastname_error = "Only letters and white space allowed";
- }
- }
- if (empty($_POST["email"])) {
- $email_error = "Email is required";
- } else {
- $email = test_input($_POST["email"]);
- // check if e-mail address is well-formed
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $email_error = "Invalid email format";
- }
- }
- if (empty($_POST["message"])) {
- $message = "";
- } else {
- $message = test_input($_POST["message"]);
- }
- if ($firstname_error == '' and $lastname_error == '' and $email_error == '' and $message_error == '' ){
- $message_body = '';
- unset($_POST['submit']);
- foreach ($_POST as $key => $value){
- $message_body .= "$key: $valuen";
- }
- $EmailFrom = localhost;
- $EmailTo = "testrepairmail69@gmail.com";
- $Subject = "New Order From tabletscreenfixer.com";
- if (mail($EmailTo, $Subject, $message)){
- $success = "Message sent, thank you for contacting us!";
- $firstname = $lastname = $email = $message = '';
- }
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement