Hi All,
Im using the below code to create basically a key depending on which product is bought, however the expiry keeps going back to the year 1967 or something like that. I cannot see anything wrong with my code. Can anyone advise where I am going wrong?
<?php
require_once('./class/paypal.php'); //when needed
require_once('./class/httprequest.php'); //when needed
//Use this form for production server
//$r = new PayPal(true);
//Use this form for sandbox tests
$r = new PayPal();
$final = $r->doPayment();
if ($final['ACK'] == 'Success') {
$key = sha1($_COOKIE['myusername']+microtime(true).mt_rand(10000,90000));
$user = $_COOKIE['myusername'];
$host = "tXYZ"; // Host name
$username = "XXXXX"; // Mysql username
$password = "@sdasdasdasdU)J&4z[X!IT"; // Mysql password
$db_name = "toasdasdas"; // Database name
$tbl_name = "keys"; // Table name
$product = $_COOKIE['product'];
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name") or die("cannot select DB");
$today = date("YYYY-MM-DD");
switch ($product)
{
case "Torn Buddy - 1 Year":
{
$timestamp = mktime(0,0,0,date("m"),date("d"),date("Y")+1);
$expiry = date("Y-m-d",$timestamp);
break;
}
case "Torn Buddy - 6 Months":
{
$timestamp =mktime(0,0,0,date("m")+6,date("d"),date("Y"));
$expiry = date("Y-m-d",$timestamp);
break;
}
case "Torn Buddy - 3 Months":
{
$timestamp =mktime(0,0,0,date("m")+3,date("d"),date("Y"));
$expiry = date("Y-m-d",$timestamp);
break;
}
case "Torn Buddy - 1 Month":
{
$timestamp =mktime(0,0,0,date("m")+1,date("d"),date("Y"));
$expiry = date("Y-m-d",$timestamp);
break;
}
case "Torn Buddy - 3 Day":
{
$timestamp =mktime(0,0,0,date("m"),date("d")+3,date("Y"));
$expiry = date("Y-m-d",$timestamp);
break;
}
}
$expiry = date("YYYY-MM-DD", $timestamp);
$sql = "INSERT INTO `keys` (`User` ,`Key` ,`Type` ,`Start` ,`End` ,`InUse`) VALUES ('$user', '$key', '$product', '$today', '$expiry', '0')";
mysql_query($sql);
}
?>
.... more code