garyed Posted December 31, 2011 Share Posted December 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/254144-is-it-safe-to-check-php-page-with-javascript/ Share on other sites More sharing options...
laffin Posted December 31, 2011 Share Posted December 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/254144-is-it-safe-to-check-php-page-with-javascript/#findComment-1302928 Share on other sites More sharing options...
garyed Posted January 1, 2012 Author Share Posted January 1, 2012 Would the php isnumeric function on all the input fields protect from sql injection since all the input should be numeric anyways? Quote Link to comment https://forums.phpfreaks.com/topic/254144-is-it-safe-to-check-php-page-with-javascript/#findComment-1302945 Share on other sites More sharing options...
AyKay47 Posted January 1, 2012 Share Posted January 1, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254144-is-it-safe-to-check-php-page-with-javascript/#findComment-1302946 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.