Dahdoul
Dahdoul

Reputation: 145

how to connect Website to MYSQL database?

Am currently working on a website(html 5) that calculate the expenses for the user, after the calculation, user has to save it as report for future purposes. So i wanna know if there is anyway to connect the website to MYSQL database or any alternative way rather than create database using java script because am a novice on Js.

thankyou

Upvotes: 4

Views: 30790

Answers (3)

Arvind Sridharan
Arvind Sridharan

Reputation: 4045

ideally you should be writing some server side code to add this sort of information to a database. that way you can secure access to authorised users (i.e. logged in users) and your queries cannot be modified on the browser by any user. you can use a programming language like PHP (with a framework like Yii, CodeIgniter) which is quite lightweight.

Upvotes: 3

Mayank Sharma
Mayank Sharma

Reputation: 829

You should use HTML5 Web SQL for this purpose. Here is link you can refer to: http://www.tutorialspoint.com/html5/html5_web_sql.htm

Upvotes: 1

Quentin
Quentin

Reputation: 943142

Browsers have no built in mechanisms for connecting to a MySQL server.

Your options are:

  • Write a browser plugin
  • Write a web service and use JavaScript to create an XMLHttpRequest object to communicate with it

The second option is the most common one (and almost certainly the best since it doesn't require that the user install a browser plugin or that you give direct access to the database to all your users).

If you want to use JavaScript, then you can create your web service with (for example) Node.js and the mysql driver in npm.

Upvotes: 2

Related Questions