Jump to content

[SOLVED] Validate in JS and PHP?


smc

Recommended Posts

Hey everyone,

 

I'm diving into client side scripting and I'm wondering if I should validate variables in both PHP and JS or if it is only needed in the JS? I'm not aware if a user can 'hack' their way around it by putting it in the URL or by other means.

 

Thanks!

Link to comment
Share on other sites

JS would be fine for verification, but ultimately you want the validation on the page that cannot be manipulated. I can create a script that would post to your script which would then bypass the jscript validation system. Use javascript to Verify, and PHP to validate as that is where the data cannot be altered anymore before database insertion.

Link to comment
Share on other sites

JS can be hacked several ways.. simplest is url inject (in the address bar type like.. javascript:void(cookie="VAR=VALUE");)

 

doesn't always work, depends on how you set up the code.. the point is, it's always best to use php over javascript, in my opinion you should get rid of the JS completely and go pure php (in validating/handling data)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.