Inserting Lists to Database" $name_l="Walgreens" $name_u="Petra Ma" $lid=1234 $uid=2345 //Checking if User 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 insert the record into MySQL database table if user dose not exist in database. //Change when Auto-Icrement is added $Sql_Query = "INSERT INTO List_Mngs(name_l,name_u,uid,lid) VALUES ('$name_l','$name_u','$uid','$lid')"; if(mysqli_query($con,$Sql_Query)){ // Show the success message. $MSG = 'List and User Registered 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); ?>