Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Joel Rivera
Joel Rivera
29,401 Points

HTML Forms

Are the forms that that we learn to create here able to prevent spam and email injectors? Or do we need to add anything to the form code?

3 Answers

Aaron Martone
Aaron Martone
3,290 Points

Hey Joel.

I haven't taken that section yet, but I cannot think that form elements alone would prevent such harassment. Usually, a combination of client-side and server-side code is needed to thwart most issues. I've seen some articles recently regarding fun, creative ways to ensure that the person using your site is a human (like little embedable games that have you drag on screen elements into certain positions)

J.T. Gralka
J.T. Gralka
20,126 Points

Hi Joel,

The HTML badges teach you the basics of creating the content and semantic markup of your webpages. In order to prevent malicious attacks to your web forms, you'll want to later learn how to start writing PHP scripts to check for malicious attacks from the server's end. (Remember that your HTML is rendered by the visitor's browser, so to write code that could prevent him or her from spamming your forms could be futile considering that you're giving him or her the ability to see the structure and behavior of your form.) Of course, with that said, you can also learn to write some simple JavaScript to interact with the form. This will allow the user to be informed of any errors in or ommisions to required fields, and it provides some seamless and interesting interactivity to your form. But, you'll almost certainly want to process the user's input on the server side (using PHP or some other server side language) to prevent the user form spamming your forms or initiating cross-site scripting (XSS) attacks.

My advise would be to become comfortable with the semantics of HTML before you start diving into JavaScript/jQuery or PHP. If you have any further questions, there're always people here on the Treehouse forums who are more than happy to offer advice and guidance.

Hope my advice is insightful!

Best,

J.T.

Joel Rivera
Joel Rivera
29,401 Points

Thanks JT. I appreciate your help.