how to connect Website to MYSQL database?

29,922

Solution 1

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.

Solution 2

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.

Solution 3

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

Share:
29,922
Dahdoul
Author by

Dahdoul

Web Developer

Updated on July 21, 2022

Comments

  • Dahdoul
    Dahdoul almost 2 years

    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