I have a problem with my php-contactformular. It has worked all the time i've used it (for more years) but now it doesn't work anymore.
It doesn't say any error message - but just says "The email was sent" (in Danish) when i push the button, and all the fields is filled. But i don't recieve any email.
This is the code:
<form method="post" action="kontakt.php" accept-charset="UTF-8">
<label>Navn:</label>
<input type="text" placeholder="Skriv dit navn her.." name="navn"/>
<label>Email:</label>
<input type="text" placeholder="Skriv din email her.." name="email"/>
<label>Telefonnummer:</label>
<input type="text" placeholder="Skriv dit telefonnummer her.." name="telefon"/>
<label >Besked:</label>
<textarea placeholder="Skriv din besked her.." cols="20" rows="5" id="kommentarbox" name="besked"></textarea>
<button type="submit" class="button">Send mail</button>
</form>
<?php
$til = 'xxxx@hotmail.com';
$email = filter_input(INPUT_POST, 'email');
$navn = filter_input(INPUT_POST, 'navn');
$telefon = filter_input(INPUT_POST, 'telefon');
$besked = filter_input(INPUT_POST, 'besked');
if (isset($_POST['email']) && isset($_POST['navn']))
{
if (empty($_POST['email']))
{
echo "<p class='fejl'>";
}
elseif (empty($_POST['navn']))
{
echo "<p class='fejl'>Input name</p>";
}
else
{
$telefon = "Mail fra " . $_POST['navn'];
$tekst = "Mail fra: " . $_POST['navn'] .
"\n \n telefon: " . $_POST['telefon'] .
"\n \n besked: " . $_POST['besked'] .
"\n \n \n \n Kontaktoplysninger: \n \n Mail: " . $_POST['email'] .
$email = $_POST['email'];
mail($til, $telefon, $tekst, $email);
echo "<p id='sendt'> Emailen er nu sendt!</p>";
}
}
I have tried to search, but i can't find anything that is the exactly same problem :(
Is there anyone who knows what is wrong with it?
Thanks!
Du skal indtaste din email
"; } elseif (empty($_POST['navn'])) { echo "Du skal indtaste dit navn
"; } else { – LoveCod Apr 29 '18 at 15:14