No Description

delete_list.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. $server = "localhost";
  3. $user = "GroceryPolice";
  4. $passwd = "P5B64tTUmGljk7cB";
  5. $db = "GroceryPolice";
  6. //Opens a new connection to the MySQL server
  7. $con= mysqli_connect($server,$user, $passwd, $db);
  8. /*
  9. // Getting the received JSON into $Received_JSON variable.
  10. $Received_JSON = file_get_contents('php://input');
  11. // decoding the received JSON and store into $obj variable.
  12. $obj = json_decode($Received_JSON,true);
  13. // Populate User name from JSON $obj array and store into $user_name variable.
  14. $name_l = $obj['name_l'];
  15. // Populate User email from JSON $obj array and store into $user_email variable.
  16. $name_u = $obj['name_u'];
  17. // Populate Password from JSON $obj array and store into $user_password variable.
  18. $uid = $obj['uid'];
  19. $lid = $obj['lid'];
  20. */
  21. echo"<h1>Deleting Lists</h1>"
  22. $con= "DELETE FROM List_Mngs WHERE lid=$lid and uid=$uid";
  23. //Checking User entered Email is already exist or not in MySQL database using SQL query.
  24. $CheckSQL = "SELECT L.name_l, L.name_u FROM List_Mngs L WHERE L.uid=$uid";
  25. // Executing SQL Query.
  26. $check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));
  27. if(isset($check)){
  28. $Duplicate_user = 'User Already Exist, Please Try Again With Different User.';
  29. // Converting the message into JSON format.
  30. $Duplicate_user_Json = json_encode($Duplicate_user);
  31. // Echo, Printing the message on screen.
  32. echo $Duplicate_user_Json ;
  33. }
  34. else{
  35. // Creating SQL query and delete the record from MySQL database table
  36. $Sql_Query = “DELETE FROM List_Mngs WHERE lid=$lid and uid=$uid";
  37. if(mysqli_query($con,$Sql_Query)){
  38. // Show the success message.
  39. $MSG = 'List Deleted Successfully' ;
  40. // Converting the message into JSON format.
  41. $json = json_encode($MSG);
  42. // Echo, Print the message on screen.
  43. echo '$json' ;
  44. }
  45. else{
  46. echo 'Try Again';
  47. }
  48. }
  49. mysqli_close($con);
  50. ?>