I am new to PHP and have only spent two weeks into it. I am currently reading "PHP and MySQL Web Development" but I am lost in what I should do in regards to form validation on a present site I am working on. I did decide to use HTML5Boilerplate for the first time and everything is coded and works great but I cant seem to figure out how to do my form. In my form all I am requiring is Name
email
and message
and I am using the $_post
method.
- Many tutorials suggested I use an array for
$name
,$email
, and$message
but I wanted to know if this is a best practice? - Should I still include JavaScript validation as a fallback?
- If I use PHP is there a way to treat all submitted content as text or is that default in PHP?
- I am wanting to create a simple form captcha with
2+2
that would require an input box of4
and I was wondering is the best way to do that withif ($_POST['submit'] && $human == '4')
? - I have read several comments on using
$email = htmlspecialchars
is bad can someone explain why?
My apologies for the thread but I have read over the week several (I beleive 15) tutorials on PHP form validation they all have their pros and cons and I want to start using PHP right. I did try to implement Eric Martin's form in my BoilerPlate but it would not work nor did I receive any browser errors in Firefox.
If it helps these are some tutorials I have read: