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">
<label for="name">namn</label><input type="text" name="name" id="name" />
<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 \
$recipient = "email@example.com";
$subject = "Contactform submit from RB";
$mailheader = "From: $mail \\r\
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
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
This means that you could potentially insert additional headers and use the contact form as a spam tool.
You can read more here: http://www.securephpwiki.com/index.php/Email_Injection
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.
This topic is now closed. New replies are no longer allowed.