javascript - Delete data with Angular and PHP -


I want to delete the data with PHP and Anlor form MySQL. This is my code:

Angular

  $ scope.delete = function () {that = this; $ Http.get ("delete.php"). Success (data) {$ scope.users.splice (that. $ Index, 1)})}}   

PHP

  $ 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";   

DB

  I have a table "customer" with subject and body cell   

The javascript code works correctly but still the fresh data is still alive !!
Where is I wrong?

As noted in the comments, your code is unsafe sql injection attacks

You must add topic to your request

angular

  $ 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

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -