Question

i got a LAMP enviornment.

Imagine the following scenario:

<form method="post" name="" id="" onsubmit="javascriptValidateFormUserInputs()">
...
</form>

As the name already says the javascriptValidateFormUserInputs(), validates inputs done by the user. If they are ok true is returned otherwise false.

If i manipulate the html clientside to onsubmit="true" no validation is done and the users invalid data is sent to the database.

I want to prevent that of course.

What to do ?

Thanks

Was it helpful?

Solution

If you are using php, then server-side validation is always better as client side validation can be tampered with.

So you just need to check if $_POST("variable") has been validated otherwise return an error.

You may follow this example - PHP Form Validation

OTHER TIPS

You should never rely on client-side validation: user can disable javascript or even perform any HTTP request to your server (outside the browser).

You need to have server-side validation in any case.

Client-side validation should only be seen as a user-friendly improvement to your base server-side validation.

  1. Never trust the client side validation through (Javascript or jquery) both of them can be easily bypassed just by turning off the Javascript in a browser.

  2. Always, always, always do and use server side validation ( yes this can add little bit load on server but still you have to use it)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top