Reputation: 4777
can i use javascript to save an item to a database using sql script?
Upvotes: 0
Views: 311
Reputation: 113
You really don't want to do this. If you store SQL in your client-side javascript, you are exposing the details and structure of your database to an attacker. Creating an AJAX method to execute passed in javascript without creating a hole and attacker could use to perform SQL Injection attacks would be quite difficult.
Upvotes: 3
Reputation: 75794
As in Javascript on the browser? No, you can't.
Hypothetically you could use AJAX techniques to push SQL commands through a server layer and thence to the database but you really, really wouldn't want to since that would be an unholy mother of all security risks.
Upvotes: 1
Reputation:
Not directly, unless you are working with a client-side database. However, you can hook JavaScript up with a server-side script (whichever backend you'd prefer) using XMLHttpRequest.
Upvotes: 4
Reputation: 17974
no, you'd have to use some serverside processing language , such as php, asp....
Upvotes: 0