Tuesday, February 8, 2022

[FIXED] PHP and Javascript Input Field Validation

Issue

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


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



Answered By - malta

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.