function add_purchase_control() { if (filter_input(INPUT_GET, 'user') && filter_input(INPUT_GET, 'bk') && filter_input(INPUT_GET, 'cost')) { $obj = new books(); $user = sanitize_string(filter_input(INPUT_GET, 'user')); $book = sanitize_string(filter_input(INPUT_GET, 'bk')); $cost = sanitize_string(filter_input(INPUT_GET, 'cost')); if ($obj->purchase_book($book, $user, $cost)) { $sms = sendPurchaseNotification($_SESSION['phone'], "Your purchase Transaction has been confirmed"); if ($sms === true) { echo '{"result":1,"message": "purchase added"}'; } else { echo '{"result":1,"message": "purchase added but sms pending"}'; } } else { echo '{"result":0,"message": "purchase addition unsuccessful"}'; } } }