No luck with contact forms, help me

Anyone have any good tips for up to date complete contact forms with validation and everything that is easy to implement?

ATM my form looks like this, no validation.

<form id="contact-form" action="email.php" method="post">
	<div class="input-wrapper1">
		<label for="name">namn</label><input type="text" name="name" id="name" />
	<div class="input-wrapper2">
		<label for="mail">epost</label><input  type="text" name="mail" id="mail" />
	<label for="msg">ärende</label><textarea name="msg" id="msg"></textarea>
	<button type="submit" name="send" id="send"><i <i class="icon-angle-circled-right"></i></button>

$name = $_POST['name'];
$mail = $_POST['mail'];
$msg = $_POST['msg'];
$formcontent="From: $name \
 Mail: $mail \
 Message: $msg";
$recipient = "";
$subject = "Contactform submit from RB";
$mailheader = "From: $mail \\r\
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";


Here is how I do it with server and client side validation. Works perfect.

thx alot. will give it a try.

There is a lot to remember when adding validation to inputs to your website. If your wanting to use a fully implemented validation procedure I would suggest using a framework like Codeignighter. I’d also stick some form of Captcha field into your form, helps stop spammers firing off a million and one emails from your server. Good luck!

It should probably be mentioned that the above code doesn’t apply any kind of validation to what is passed to the mail function.
This means that you could potentially insert additional headers and use the contact form as a spam tool.

You can read more here:

Mine accounts for headers and etc. I pieced it together a long while back. Quite happy with it. Form processing is probably the hardest thing I’ve ever done to get right. Usually if you grab some one piece of code it has like 10 pages of mumbo jumbo. I was never ok with that. I needed to know what it was doing.