Guest User

Untitled

a guest
Mar 18th, 2018
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <div ng-app="myapp" >
  2. <div ng-controller="myCtrl" ng-init="email='<?php echo "kashfi@gmail.com"; ?>'" >
  3. <input ng-model="listname" type="text" placeholder="New List Name" class="inputy-smart" >
  4. <button ng-click="addListName()" class="btn btn-primary btn-sm" >Add</button>
  5. {{listadded}}
  6.  
  7. </div>
  8. </div>
  9.  
  10. var app = angular.module("myapp",[]);
  11. app.controller("myCtrl",function($scope,$http) {
  12. $scope.addListName=function() {
  13. $http.post(
  14. "practicephp.php",
  15. {'category':'todo','user-email': $scope.email, 'listName':$scope.listname}
  16. ).then(function(response) {
  17. $scope.listadded = response.data;
  18.  
  19. });
  20. };
  21. });
  22.  
  23. $userdata = json_decode(file_get_contents("php://input"));
  24. // validating & sanitizing data with function...
  25. function check_data($data) {
  26. $data = trim($data);
  27. $data = stripslashes($data);
  28. $data = htmlspecialchars($data);
  29. return $data;
  30.  
  31. }
  32. if(count($userdata) > 0 ) {
  33.  
  34. $todo_list = check_data($userdata->listName);
  35. $category = check_data($userdata->category);
  36. $user_email = check_data($userdata->user-email);
  37.  
  38.  
  39. //Insert Data to database...
  40. $todolists = $connect->query("INSERT INTO userlists (user_email,list_category,list_name) VALUES ('$user_email','$category','$todo_list')");
  41. if($todolists) {
  42. echo "Name Inserted";
  43. }else {
  44. echo "Error";
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment