1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
-
- $server = "localhost";
- $user = "GroceryPolice";
- $passwd = "P5B64tTUmGljk7cB";
- $db = "GroceryPolice";
-
- //Opens a new connection to the MySQL server
-
- $con= mysqli_connect($server,$user, $passwd, $db);
-
- /*
- // Getting the received JSON into $Received_JSON variable.
- $Received_JSON = file_get_contents('php://input');
-
- // decoding the received JSON and store into $obj variable.
- $obj = json_decode($Received_JSON,true);
-
- // Populate User name from JSON $obj array and store into $user_name variable.
- $name_l = $obj['name_l'];
-
- // Populate User email from JSON $obj array and store into $user_email variable.
- $name_u = $obj['name_u'];
-
- // Populate Password from JSON $obj array and store into $user_password variable.
- $uid = $obj['uid'];
- $lid = $obj['lid'];
- */
-
- echo"<h1>Deleting Lists</h1>"
- $con= "DELETE FROM List_Mngs WHERE lid=$lid and uid=$uid";
-
-
-
- //Checking User entered Email is already exist or not in MySQL database using SQL query.
- $CheckSQL = "SELECT L.name_l, L.name_u FROM List_Mngs L WHERE L.uid=$uid";
-
- // Executing SQL Query.
- $check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));
-
- if(isset($check)){
-
- $Duplicate_user = 'User Already Exist, Please Try Again With Different User.';
-
- // Converting the message into JSON format.
- $Duplicate_user_Json = json_encode($Duplicate_user);
-
- // Echo, Printing the message on screen.
- echo $Duplicate_user_Json ;
-
- }
- else{
-
- // Creating SQL query and delete the record from MySQL database table
- $Sql_Query = “DELETE FROM List_Mngs WHERE lid=$lid and uid=$uid";
-
-
- if(mysqli_query($con,$Sql_Query)){
-
- // Show the success message.
- $MSG = 'List Deleted Successfully' ;
-
- // Converting the message into JSON format.
- $json = json_encode($MSG);
-
- // Echo, Print the message on screen.
- echo '$json' ;
-
- }
- else{
-
- echo 'Try Again';
-
- }
- }
- mysqli_close($con);
- ?>
|