<?php
if (!isset($id)) $id=$_SESSION['member_details_array']['id'];
$dbc = dbc::instance();
$result = $dbc->prepare("SELECT expire_date from wmm_members where id=:id ");
$result->bindParam(':id', $id, PDO::PARAM_INT);
$rows = $dbc->executeGetRows($result);
$expire_date=$rows[0]['expire_date'];
include_once("header.html");
include("paypal-logos.html");
$id_input = "<input type=\"hidden\" name=\"id\" value=\"$id\">\n";
if(!isset($paypal_option_id)) include("paypal-select-option-renewal.html");
else
{
$result = $dbc->prepare("SELECT * from wmm_paypal_items where id=:id ");
$result->bindParam(':id', $paypal_option_id, PDO::PARAM_INT);
$rows = $dbc->executeGetRows($result);
$duration = $rows[0]['duration'];
$date_now = time();
//ensure the account does not get deleted before IPN returns - could be several days old for a returning new member
if ($date_now>$expire_date) $expire_date=$date_now;//set expire date to today if not in the future
$update_query = "UPDATE wmm_members SET
duration='$duration',
expire_date='$expire_date'
where id=:id ";
$result = $dbc->prepare($update_query);
$result->bindParam(':id', $id, PDO::PARAM_INT);
$result = $dbc->execute($result);
include("paypalform.html");
}
?>