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

PHP

Validate paypal form to stop edited HTML to be sent? [Shirts4Mike]

How would you go about validating that the HTML matches the price or shirt id, to stop people from submitting forms with an edited name or size?

1 Answer

Patrick Cooney
Patrick Cooney
12,216 Points

I would write some custom JavaScript to do string comparisons on the client side. You can do it server-side but its not as efficient.

Couldn't the potentially mischievous user just modify the javascript to validate the fake form?

Patrick Cooney
Patrick Cooney
12,216 Points

You know, that's a really good question. I know you can inspect and edit JavaScript with most developer tools but I'm not sure if it would persist through the form submission process. If you're really worried about it do it server side. It takes a little longer for the user but if it gives you peace of mind it may be worth it.

Either way you choose to do it you'll just do some simple string comparisons.