Friday, 15 June 2012

javascript - Delete data with Angular and PHP -



javascript - Delete data with Angular and PHP -

i want delete info php , angular form mysql. code :

angular

$scope.delete = function(){ = this; $http.get("delete.php").success(function(data){ $scope.users.splice(that.$index, 1) }) }

php

$data = json_decode(file_get_contents("php://input")); $subject = mysql_real_escape_string($data->subject); mysql_select_db("angular") or die(mysql_error()); $tbl="customers"; $subject = $_get ['index']; $sql="delete $tbl subject = '$subject'"; $result = mysql_query($sql, $con); if($result){ echo "deleted successfully"; }else { echo "error"; }

db

i have table "customers" subject , body cell

javascript code worked correctly after refreshing info still live !! wrong ?

as mentioned in comments, your code vulnerable sql injection attacks

you need add together subject request

angular

$scope.delete = function(){ var subject = // subject somehow ... = this; $http.get("delete.php?subject=" + subject) .success(function(data){ $scope.users.splice(that.$index, 1) }) }

php

$tbl="customers"; $subject = $_get ['subject']; $sql="delete $tbl subject = '$subject'"; $result = mysql_query($sql, $con); if($result){ echo "deleted successfully"; }else { echo "error"; }

javascript php mysql angularjs

No comments:

Post a Comment