reggaeboss — 2013-08-21T15:20:54-04:00 — #1
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!";
picnictutorials — 2013-08-21T15:30:30-04:00 — #2
reggaeboss — 2013-08-21T15:44:37-04:00 — #3
thx alot. will give it a try.
belansus — 2013-08-25T04:34:49-04:00 — #4
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!
pullo — 2013-08-25T10:34:14-04:00 — #5
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
picnictutorials — 2013-08-25T18:01:11-04:00 — #6
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.