i've got some Problems with my Contact-Form. I tried to get the form i want to use from some Tutorials, but its not working. But i dont know why :D
I hope you guys can help me, maybe its just a little error :) Should it work, or do i have to edit some settings on my Webspace?
<?php
if (isset($_POST["submit"])) {
$firma = $_POST['inputFirma'];
$vorname = $_POST['inputVorname'];
$telefon = $_POST['inputTelefon'];
$plzort = $_POST['inputPlzOrt'];
$adresse = $_POST['inputStraßeHausnummer'];
$firma = $_POST['input'];
$name = $_POST['inputName'];
$email = $_POST['inputEmail'];
$message = $_POST['inputNachricht'];
$human = intval($_POST['inputHuman']);
$from = 'Demo Contact Form';
$to = 'hasse.j@gmx.de';
$subject = 'Nachricht des Kontaktformulars';
$body = "From: $firma\n $vorname\n $name\n PLZ/Ort: $plzort\n Adresse: $adresse\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Bitte geben Sie Ihren Namen ein';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Bitte geben Sie eine echte E-Mail-Adresse ein';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Bitte geben Sie eine Nachricht ein';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Bitte rechnen Sie erneut';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
}
?>
and the HTML:
<form action="" method="post">
<div class="form-group">
<label for="inputFirma">Firma</label>
<input type="text" class="form-control" id="inputFirma">
</div>
<div class="form-group">
<label for="inputName">*Name</label>
<input type="text" class="form-control" id="inputName">
</div>
<div class="form-group">
<label for="inputVorname">Vorname</label>
<input type="text" class="form-control" id="inputVorname">
</div>
<div class="form-group">
<label for="inputStraßeHausnummer">Straße und Hausnummer</label>
<input type="text" class="form-control" id="inputStraßeHausnummer">
</div>
<div class="form-group">
<label for="inputPlzOrt">Ort / Postleitzahl</label>
<input type="text" class="form-control" id="inputPlzOrt">
</div>
<div class="form-group">
<label for="inputTelefon">Telefon</label>
<input type="text" class="form-control" id="inputTelefon">
</div>
<div class="form-group">
<label for="inputEmail">*E-Mail</label>
<input type="email" class="form-control" id="inputEmail">
</div>
<div class="form-group">
<label for="inputNachricht">*Ihre Nachricht</label>
<textarea type="text" class="form-control" cols="40" rows="5" id="inputNachricht"></textarea>
</div>
<br>
<div class="form-group">
<label for="inputHuman" class="col-sm-2 control-label">2 + 3 = ?</label>
<input type="text" class="form-control" id="inputHuman">
</div>
<br>
<button type="submit" class="btn btn-primary margin-bot-50">Senden</button>
</form>