I have made a calculator in PHP and it works fine. But I haven't used validation. What do you guys think, should I use Javascript or PHP for validation?
5
-
2js for user convenience and php because you can never trust anything that comes from the user / visitor. So you need server-side validation at least.jeroen– jeroen2015-12-31 10:19:05 +00:00Commented Dec 31, 2015 at 10:19
-
Php validation is better.zed Blackbeard– zed Blackbeard2015-12-31 10:19:41 +00:00Commented Dec 31, 2015 at 10:19
-
1So that means both? If I use Php validation it makes the code very lengthy. Does that affect the performance of the page?user5237857– user52378572015-12-31 10:20:47 +00:00Commented Dec 31, 2015 at 10:20
-
1@user5237857 Does it prevent you to have both? Solution: Have both!Praveen Kumar Purushothaman– Praveen Kumar Purushothaman2015-12-31 10:21:46 +00:00Commented Dec 31, 2015 at 10:21
-
1Corubba, did I ask you if its a duplicate or not? I didn't know that there is already a question here.user5237857– user52378572015-12-31 10:33:17 +00:00Commented Dec 31, 2015 at 10:33
Add a comment
|
3 Answers
As a general rule think this: Server side validation is mandatory: not validated data could harm your app or be used in a wrong way
Client side validation is more used to help users to fill correctly your forms, but you can't trust it, as client data could be easily altered from users
Of course, the best would be to use the two together