123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
-
- $server = "localhost";
- $user = "GroceryPolice";
- $passwd = "P5B64tTUmGljk7cB";
- $db = "GroceryPolice";
-
-
-
- $con= mysqli_connect($server,$user, $passwd, $db);
-
-
-
- $Received_JSON = file_get_contents('php://input');
-
-
- $obj = json_decode($Received_JSON,true);
-
-
- $name_l = $obj['name_l'];
-
-
- $store = $obj['store'];
-
-
- $uid = $obj['uid'];
-
-
-
-
-
- $CheckSQL = "SELECT * FROM `List` L WHERE L.uid=$uid and L.name_l='$name_l'";
-
-
- $check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));
-
-
-
- if(empty($name_l) or empty($store) or empty($uid)){
-
- $MSG = 'Field is empty. Enter information again...' ;
-
-
- $json = json_encode($MSG);
-
-
-
- echo $json;
-
- }
-
- else{
- if(isset($check)){
-
- $Duplicate_user = 'List Name Already Exist, Please Try Again';
-
-
- $Duplicate_user_Json = json_encode($Duplicate_user);
-
-
- echo $Duplicate_user_Json ;
-
- }
- else{
-
-
- $Sql_Query = "INSERT INTO `List`(`name_l`, `store`, `uid`) VALUES ('$name_l','$store','$uid')";
-
-
- if(mysqli_query($con,$Sql_Query)){
-
-
- $MSG = 'List Registered Successfully' ;
-
-
- $json = json_encode($MSG);
-
- echo $json;
- }
- else{
- $MSG='Not Registered Correctly';
- $json = json_encode($MSG);
- echo $json;
-
- }
- }
- }
- mysqli_close($con);
- ?>
|