Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="" method="POST">
- <ul class="form-style-1">
- <li>
- <input type="text" id="mail-name" name="name" class="field-divided" maxlength="15" placeholder="Voornaam *" /> <input type="text" id="mail-lastname" name="lastname" class="field-divided" maxlength="15" placeholder="Achternaam" >
- </li>
- <li>
- <input type="text" id="mail-email" name="email" placeholder="E-mail *" class="field-long" maxlength="40" >
- </li>
- <li>
- <input type ="text" id="mail-phone" name="phone" placeholder="Telefoonnummer" class="field-long" maxlength = "15">
- </li>
- <button class="mail-submit" id="mail-submit" type="submit" name="submit">Versturen</button>
- <span style="color: #0184b2; text-align: center; font-size: 20px; margin: 0 auto; display: block; padding-top: 10px;" class="form-message"></span>
- </ul>
- </form>
- $("form").on("submit",function(event){
- event.preventDefault();
- var name = $("#mail-name").val();
- var lastname = $("#mail-lastname").val();
- var email = $("#mail-email").val();
- var phone = $("#mail-phone").val();
- var subject = $("#mail-subject").val();
- var information = $("#mail-information").val();
- $.post("donation-contact.php",
- {
- name: name,
- lastname: lastname,
- email: email,
- phone: phone,
- submit: "yes"
- },
- function(data){
- $(".form-message").html( data );
- }
- );
- });
- <?php
- if (isset($_POST['submit'])) {
- $email_to = "#";
- $email_subject = "#";
- $name = $_POST['name'];
- $lastname = $_POST['lastname'];
- $email = $_POST['email'];
- $phone = $_POST['phone'];
- $errorEmpty = false;
- $errorEmail = false;
- if (empty($name)) {
- echo "<span class='form-error'>Voer de verplichte velden in!</span>";
- $errorEmpty = true;
- }
- elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- echo "<span class='form-error'>Geef een geldig E-mail!</span>";
- $errorEmail = true;
- }
- else {
- $formcontent=" Naam: $name nn Achternaam: $lastname nn Email: $email nn Telefoon: $phone";
- $mailheader = "From: ".$_POST["email"]."rn";
- $headers = "From: ". htmlspecialchars($_POST['name']) ." <" . $_POST['email'] . ">rn";
- $headers .= "Reply-To: " . $_POST['email'] . "rn";
- $headers .= "MIME-Version: 1.0rn";
- $headers .= "Content-Type: text/html; charset=ISO-8859-1rn";
- mail($email_to, $email_subject, $formcontent, $mailheader);
- echo "<span class='form-success'>De mail is verzonden!</span>";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment