How to insert data into DB with jQuery/Javascript without using PHP?

Question:

I'm learning Javascript and jQuery and I'm looking to make a small website to test data entry into a database. I have no knowledge of PHP, I would like to know if it is possible to insert data into a database only with Javascript or jQuery. I would also like to know what is the most efficient/practical way you recommend for this task.

Answer:

Forget about that idea. Accessing the database directly via javascript would create serious security problems in your application, after all with a simple firebug, anyone could change the javascript or use the javascript console itself to place any SQL command, including a DROP DATABASE there.

And before that, you'd have to make do with managing the database connection directly in javascript, and that's not going to be easy, if that's even possible.

Also, even if you can make javascript connect to the database, since javascript runs in the browser, you would have to expose the SQL server on a public network with the login and password obtainable from javascript. And then you've already given your database to any hacker on the internet to do whatever they want.

Scroll to Top