javascript - Delete data with Angular and PHP -
I want to delete the data with PHP and Anlor form MySQL. This is my code:
Angular PHP DB The javascript code works correctly but still the fresh data is still alive !! You must add angular
$ scope.delete = function () {that = this; $ Http.get ("delete.php"). Success (data) {$ scope.users.splice (that. $ Index, 1)})}}
$ data = json_decode (file_get_contents ("php: // input")); $ Theme = mysql_real_escape_string ($ data-> topics); Mysql_select_db ("angular") or die (mysql_error ()); $ Tbl = "customers"; $ Theme = $ _GET ['index']; $ Sql = "$ tbl, where topic = '$ subject'"; $ Result = mysql_query ($ sql, $ con); If ($ result) {echo "successfully deleted"; } And {echo "error";
I have a table "customer" with subject and body cell
Where is I wrong? As noted in the comments, your code is unsafe sql injection attacks
topic to your request
$ Scope.delete = function () {var subject = // Get the topic anyway ... this = this; $ Http.get ("delete.php? Subject =" + topic) .sevate (function) {$ scope.users.splice (that. $ Index, 1)}}} < P> php
$ tbl = "subscriber"; $ Theme = $ _GET ['subject']; $ Sql = "$ tbl, where topic = '$ subject'"; $ Result = mysql_query ($ sql, $ con); If ($ result) {echo "successfully deleted"; } And {echo "error"; }
Comments
Post a Comment