Page 1 of 1

how to limit HTML input in a form box

Posted: Wed Dec 04, 2002 7:15 pm
by SL-Cowsrule
I was just wondering if you could do this, and if so, how.

Thanks,
CoW

Posted: Wed Dec 04, 2002 10:38 pm
by volka
e.g.

Code: Select all

<input type="text" name="xyz" maxlength="20" />
But the client may choose to ignore it or the user can transmit the data in another way, so you have to also check the input server-side (e.g. by strlen()) if necessary.

Posted: Thu Dec 05, 2002 9:14 pm
by SL-Cowsrule
sorry for not making myself clear, i meant if i could disable the persons ability to use html code, or have the code be taken out or something, or maybe not displayed from a database. Im not sure if i can use an HTML function or if this is php.
i looked at w3c.org under the form syntax and didnt see anything... so imguessing this is php.
Thanks,
CoW

Posted: Thu Dec 05, 2002 9:26 pm
by mydimension
yep, php has great functionality for that. see http://php.net/strip-tags

Posted: Sun Dec 08, 2002 12:43 am
by Sunthas
Using MySQL and PHP and Apache latest, I have only had to convert apersands and use the addslashes command to get the data to store and retrieve correctly.

For example I would type in something like:

Code: Select all

So and so said this "Blah Blah Blah!" If you want to read more about blah check it out <a href='http://www.blah.com/something.php?one=1&two=2'>here</a>.
Ofcourse when this gets pulled out later the HTML is converted which is what I want and gets displayed correctly. The slashes that might be added before the Single or Double Quotes never have to be changed again. The ampersand would be fine left alone in the database and for display purposes seems to display fine in IE6, but for HTML401Transitional compliance needs to be changed to &