prepare($sql); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->execute(); $res = $stmt->fetch(PDO::FETCH_ASSOC); if ($_SERVER['REQUEST_METHOD'] === 'POST' && $stmt->rowCount() >= 1) { $cur = date('Y-m-d', strtotime('+30 days')); $status = 'Active'; $sql = "UPDATE member SET membership_status = :membership_status, expired_date =:expired_date WHERE userid = :userid"; $stmt = $conn->prepare($sql); $stmt->bindParam(':membership_status', $status, PDO::PARAM_STR); $stmt->bindParam(':expired_date', $cur, PDO::PARAM_STR); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->execute(); header('location: ./Profile.php'); die(); } else if($_SERVER['REQUEST_METHOD'] === 'POST' && $stmt->rowCount() <= 0) { $cur = date('Y-m-d', strtotime('+30 days')); $status = 'Active'; $sql = "INSERT INTO member (membership_status, expired_date, userid) VALUES (:membership_status, :expired_date, :userid)"; $stmt = $conn->prepare($sql); $stmt->bindParam(':membership_status', $status, PDO::PARAM_STR); $stmt->bindParam(':expired_date', $cur, PDO::PARAM_STR); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->execute(); header('location: ./Profile.php'); die(); } $sql = "SELECT users.*, member.* FROM users INNER JOIN member ON member.memberid = users.userid WHERE memberid = :userid;"; $stmt = $conn->prepare($sql); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->execute(); $new_membership_required = false; $users['expired_date'] = date('Y-m-d', strtotime('+30 days')); if($stmt->rowCount() == 0) { $users['membership_status'] = "Inactive"; $new_membership_required = true; /* $cur = date('Y-m-d', strtotime('+30 days')); $sql = "INSERT INTO member (membership_status, expired_date, memberid) VALUES ('Active', :expired_date, :userid)"; $stmt = $conn->prepare($sql); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->bindParam(':expired_date', $cur, PDO::PARAM_STR); $stmt->execute(); //header('location: ./Profile.php'); //die(); */ } else { $res = $stmt->fetch(PDO::FETCH_ASSOC); $users['membership_status'] = $res['membership_status']; if($users['expired_date'] < date('Y-m-d')) { $new_membership_required = true; } /* $users = $stmt->fetch(PDO::FETCH_ASSOC); $sql = "UPDATE member SET expired_date = :expired_date, membership_status = :membership_status WHERE memberid = :userid"; $stmt = $conn->prepare($sql); $stmt->bindParam(':expired_date', $users['expired_date'], PDO::PARAM_STR); $stmt->bindParam(':membership_status', $users['membership_status'], PDO::PARAM_STR); $stmt->bindParam(':userid', $_SESSION['userid'], PDO::PARAM_INT); $stmt->execute(); header('location: ./Profile.php'); die(); */ } ?> Renew Membership

Renew Membership

Your current membership status:

Your membership is valid until:

Your new membership will be valid until:

Cancel