Ver código fonte

Upload files to 'Sprint#1'

valerie.yace 4 anos atrás
pai
commit
74ec0a46a6
1 arquivos alterados com 77 adições e 0 exclusões
  1. 77
    0
      Sprint#1/delete_list.php

+ 77
- 0
Sprint#1/delete_list.php Ver arquivo

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