How does one validate input from HTML forms using PHP ? I would need to input the data in a MySQL DB
Taking into consideration that the form contains input and textarea feilds and drop down-down menus. Well I'm really concerned with the input and textarea (as the user is forced to select the option from the drop-down menu)....how does one validate what the user enters in the input and textarea feilds...afterall my form is setup so that whatever the user enters as an input it would be a valid
input.It's just like the form that I filled out to make the very same post :?
Is there anything I need to even verify ? Also In my DB I use the data type TINYTEXT for my Subject and for my Message body (I call it somthing else though) I use the data type TEXT
If I'm not mistaken the data types can hold up to the following :
For TINYTEXT, 255 characters which would be same as VARCHAR(255)
AND for TEXT it is 65535 characters. (65535 chracters is appropriate for what I'm doing)
(The most I see that I can do is make sure that what the user enters falls within these limits...right ? Are there more appropriate data types)
I have also made sure that I have set the wrap attribute in the textarea tag to wrap="soft"...trying to follow W3C officila HTML 4.0 standard (this ensure that the lines will appear to wrap in the textarea however they are submitted as a single line to the DB for INSERTION)
I also read the following at PHPNexus
In some configurations, magic_quotes_gpc (the feature that automatically adds slashes to all input) is actually set to OFF. You can use the function get_magic_quotes_gpc() to see if it's on or not (it returns true or false). If it returns false, simply use addslashes() to add slashes to all of the input (it is easiest if you use $POST, $GET, and $_COOKIE or $HTTP_POST_VARS, $HTTP_GET_VARS, and $HTTP_COOKIE_VARS, instead of globals because you could step through those arrays using a foreach() loop and add slashes to each one).
So I turned on magic_quotes_gpc.....
I's there anything else I can do ? I would be very much appreciative of any suggestion ?