-5

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
  • 2
    js 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. Commented Dec 31, 2015 at 10:19
  • Php validation is better. Commented Dec 31, 2015 at 10:19
  • 1
    So that means both? If I use Php validation it makes the code very lengthy. Does that affect the performance of the page? Commented Dec 31, 2015 at 10:20
  • 1
    @user5237857 Does it prevent you to have both? Solution: Have both! Commented Dec 31, 2015 at 10:21
  • 1
    Corubba, did I ask you if its a duplicate or not? I didn't know that there is already a question here. Commented Dec 31, 2015 at 10:33

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

2

It depends on your requirements.

  • If you want to speed up your output, but give less priority to security, then use client side scripts such as JavaScript.
  • If you want more security and wouldn't care for speed, then use server side scripts such as PHP.

Comments

0

Better you can have both Client Side and Server Side validation.

Server Side validation will help if user disabled Javascript on his Browser

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.