this is my script which activates the user one they have paid. For some reason their expire date is really off and random. Here is my script:
This package is only suppose to last 30 days,
Thanks.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require '../includes/db.php';
if(isset($_POST['item_name'], $_POST['item_number'])) {
$item_info = explode('_', $_POST['item_number']);
$packageid = $item_info[0];
$userid = $item_info[1];
$sth = $odb->prepare("SELECT * FROM `plans` WHERE `ID` = :id");
$sth->bindParam(':id', $packageid);
$sth->execute();
$data = $sth->fetch(PDO::FETCH_ASSOC);
$days_to_unixtime = strtotime("{$data['mbt']} days");
$sth = $odb->prepare("UPDATE `users` SET `membership` = :packageid, `expire` = :expire WHERE `ID` = :userid");
$sth->bindParam(':packageid', $packageid);
$sth->bindParam(':expire', $days_to_unixtime);
$sth->bindParam(':userid', $userid);
$sth->execute();
file_put_contents('/tmp/accessed.txt', 'yes');
}
You forgot the + in front of number of days.
strtotime("+ {$data['mbt']} days");