So I can't really find the mistake I made, it was working earlier.. I have a HTML contact form that I validate with JS, when it's true, I change the form action to the php file, where it takes all the information of the contact form and sends it to my mail..
I can provide a live-version if necessary..
Example from this site: http://www.freecontactform.com/email_form.php
I only deleted the php validation..
JAVASCRIPT
function validateForm() {
var voornaam = document.forms["contactform"]["voornaam"].value;
var achternaam = document.forms["contactform"]["achternaam"].value;
var straat = document.forms["contactform"]["straat"].value;
var huisnummer = document.forms["contactform"]["huisnummer"].value;
var gemeente = document.forms["contactform"]["gemeente"].value;
var postcode = document.forms["contactform"]["postcode"].value;
var email = document.forms["contactform"]["email"].value;
var bericht = document.forms["contactform"]["bericht"].value;
if (voornaam == null || voornaam == "") {
alert("Je moet je voornaam invullen");
return false;
} else if (achternaam == null || achternaam == "") {
alert("Je moet je achternaam invullen");
return false;
} else if (straat == null || straat == "") {
alert("Je moet je straat invullen");
return false;
} else if (huisnummer == null || huisnummer == "" || isNaN(huisnummer)) {
alert("Je moet je huisnummer invullen en enkel cijfers gebruiken");
return false;
} else if (gemeente == null || gemeente == "") {
alert("Je moet je gemeente invullen");
return false;
} else if (postcode == null || postcode == "" || isNaN(postcode)) {
alert("Je moet je postcode invullen en enkel cijfers gebruiken");
return false;
} else if (email == null || email == "") {
alert("Je moet je email-adres invullen");
return false;
} else if (bericht == null || bericht == "") {
alert("Je bericht is leeg! ");
return false;
} else {
document.forms["contactform"].action = "send_form_email.php";
}
}
PHP FILE
<?php
$email_to = "PERSONAL EMAIL";
$email_subject = "Test email form";
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$straat = $_POST['straat'];
$huisnummer = $_POST['huisnummer'];
$gemeente = $_POST['gemeente'];
$postcode = $_POST['postcode'];
$email = $_POST['email'];
$bericht = $_POST['bericht'];
$email_message = "Informatie over de bezoeker\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Voornaam: " . clean_string($voornaam) . "\n";
$email_message .= "Achternaam: " . clean_string($achternaam) . "\n";
$email_message .= "Adres: " . clean_string($straat) . "\n";
$email_message .= "Huisnummer: " . clean_string($huisnummer) . "\n";
$email_message .= "Gemeente: " . clean_string($gemeente) . "\n";
$email_message .= "Postcode: " . clean_string($postcode) . "\n\n";
$email_message .= "Bericht: " . clean_string($bericht) . "\n";
$email_from = $email;
// create email headers
$headers = 'From: ' . $email_from . "\r\n" .
'Reply-To: ' . $email_from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
HTML
<form id="contactform" name="contactform" method="post">
<div style="text-align: center; margin-left: 10%;">
<table width="800px" id="table">
<tr>
<td>
<h1 style="font-family: 'Aller Bold';">Neem contact met ons op:</h1>
</td>
</tr>
<tr>
<td>
<input type="text" name="voornaam" class="inputcontact" size="40" placeholder="Voornaam">
</td>
</tr>
<tr>
<td>
<input type="text" name="achternaam" class="inputcontact" size="40" placeholder="Achternaam">
</td>
</tr>
<tr>
<td>
<input type="text" name="straat" class="inputcontact" size="40" placeholder="Straat">
</td>
</tr>
<tr>
<td>
<input type="text" name="huisnummer" class="inputcontact" size="40" placeholder="Huisnummer"
maxlength="5">
</td>
</tr>
<tr>
<td>
<input type="text" name="gemeente" class="inputcontact" size="40" placeholder="Gemeente">
</td>
<tr>
<td>
<input type="text" name="postcode" class="inputcontact" size="40" placeholder="Postcode"
maxlength="4">
</td>
</tr>
<tr>
<td>
<input type="text" name="email" class="inputcontact" size="40" placeholder="E-mailadres"> <br> <br>
</td>
</tr>
<tr>
<td>
<textarea name="bericht" class="inputcontact" placeholder="Typ je bericht hier.." rows="4"
cols="50"></textarea> <br> <br>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Verzenden" id="submitcontact" onclick="validateForm()">
<br>
<br>
</td>
</tr>
</table>
</div>
</form>