I've made a simple web page for business clients that operates on MySQL database used mainly by our B2C Prestashop based e-shop. We're using shared hosting. This website is mostly based on jQuery jTable (jtable.org) and is meant to show current, approximate stock of products.
I've used jQuery jTable 'starter pack' and created a simple front-end view for our partners. It looks more or less like the one in jTable tutorial:
$(document).ready(function () {
//Prepare jTable
$('#PeopleTableContainer').jtable({
title: 'Product Availability',
actions: {
listAction: 'someconfigfile.php?action=list',
},
fields: {
column1: {
title: 'column1',
width: '70%',
key: true
},
column2: {
title: 'column2',
width: '30%'
}
}
});
//Load person list from server
$('#PeopleTableContainer').jtable('load');
});
As I only want to show data I have in MySQL database, I've prepared read-only user and I'm using his credentials to access database. As seen in jQuery script, I'm accessing database through someconfigfile.php and 'list' action.
The someconfigfile.php includes MySQL connection string and also my SQL query for populating the table in front-end view. What I want to do for security purposes is to put someconfigfile.php in directory above my public_html folder. Folder containing HTML, PHP and CSS files for front-end will stay below public_html.
My question is:
- Will my password be accessible by anyone if I put it above public_html? My whole front-end code is this jQuery jTable above.
- Am I vulnerable to SQL Injection if I only get data with mysql_fetch_assoc($result) and then print json_encode of the array()? User cannot enter any data here.
Edit: Please also note that from jTable CRUD functions I've only left Read option. Create, Update and Delete options have been removed.