I have read previous topics but can’t find anything to help me telling wat’s wrong in my code.
It tells me all the time that the email is incorrect.
[code=php]<div id=”valkommen”>
<h2 class=”cleartopmargin”>Kontakta oss </h2>
<br />
<br />
<?php
function valid_email($email) {
$pattern = “/^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-w]*[0-9a-zA-Z])*.)+[a-zA-Z]{2,9})$/”;
if (preg_match($pattern, $email)) {
return true;
}
else {
return false;
}
}
if (isset($_POST[‘sendemail’]) && !empty($_POST[‘name’]) && !empty($_POST[‘subject’]) && !empty($_POST[’email’]) && !empty($_POST[‘msg’])) {
if (!valid_email($email)) { echo “<p class=”red”>You typed an unvalid email adress<br /><br /></p>”; }
else {
$to = “[email protected]”;
$subject = “Från Testzoneformuläret: ” . $_POST[‘subject’];
$msg = “Skickat från formuläret”.”rnrn”.”Från: “.$_POST[‘name’].”rn”.”E-post: “.$_POST[’email’].”rnrn”.”Meddelande: “.”rn”.$_POST[‘msg’];
$headers = “From: [email protected]”;
mail($to, $subject, $msg, $headers);
echo “thx!”;
}}
elseif (isset($_POST[‘sendemail’])) {
echo “<p class=”red”>You forgot to type in all fields!</p>”;
}
?>
<form action=”index.php?p=contact” method=”POST”>
Namn<br />
<input name=”name” type=”text” class=”input” size=”25″ />
<br />
E-postadress<br />
<input name=”email” type=”text” class=”input” size=”25″ />
<br />
Ärende<br />
<select name=”subject” size=”1″>
<option value=”Information”>Information</option>
<option value=”Annonsering”>Annonsering</option>
<option value=”Forum”>Forum</option>
<option value=”Tester”>Tester</option>
<option value=”Support”>Support</option>
<option value=”Övrigt”>Övrigt</option>
</select>
<br />
<br />
Meddelande<br />
<textarea name=”msg” rows=”10″ cols=”35″ class=”textfield”></textarea>
<br />
<br />
<input type=”submit” value=”Skicka” name=”sendemail” class=”buttons” />
</form>
</div>