<?php include_once "../database.php"; $json = file_get_contents('php://input'); $request = json_decode($json, true); $userid = isset($request["userid"]) ? $request["userid"] : ""; echo json_encode(getSubsription($userid));
function addSubscriptionForMobile($id, $userid) { $db = conn(); $date = getSubsription($userid); if (empty($date)) { $sdate = date('Y-m-d'); } else { foreach ($date as $s) { $sdate = $s['endDate']; } } $wdate = new DateTime($sdate); $wdate->add(new DateInterval('P30D')); $edate = $wdate->format('Y-m-d'); $type = 'M'; $db->exec("INSERT INTO subscriptions(SPID, subscriberID, startDate, endDate, subtype)VALUES('" . $id . "','" . $userid . "','" . $sdate . "','" . $edate . "','" . $type . "')"); $db = null; }