Jump to content

Is it safe to check php page with javascript?


garyed

Recommended Posts

I wasn't sure where to post this so I apologize if this is the wrong forum. I have a php page with over 50 numerical inputs on a form. A lot of the inputs are used to get data out of the mysql database so I want to be safe from sql injection. Is it safe to use a javascript onsubmit function that will not allow the form to be submitted if there is any non numeric data entered by the user? I've already written the function & it works fine but I'm not sure how much protection it gives me. Any feedback welcome.   

Link to comment
Share on other sites

Javascript only prevents a refresh from happening, it will not proect against invalid data being sent to the server.

there are many tools out there which disable and alter javascript. So it's not a good replacement system to a php script. It works well in conjunction.

Link to comment
Share on other sites

Javascript only prevents a refresh from happening, it will not proect against invalid data being sent to the server.

there are many tools out there which disable and alter javascript. So it's not a good replacement system to a php script. It works well in conjunction.

you most certainly can filter data with javascript, however it is not advisable because the user can disable javascript, thus disabling your js filtering.

If you are going to go the javascript route, make sure that you have some back end code that will check the user input as well.

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.