Forum Moderators: coopster
And then it will perform an SQL INSERT into a database with a date 1 day, week or month from now.
Then i need a seperate countdown script that grabs this expiry date and counts-down until that date.
how hard is this to do? any pointers or help is greatly appreciated!
Thanks so much for any contributions!
Adam.
In my limited knowledge I would as you say set the date into mysql I am not clear on what its counting down to though but assume its to stop someone logging in after the expirey, you can ask the login page to check current date against the mysql date to see if they still are allowed to login if not send them to the re-apply page.
It's not difficult, am I on the right track?
<?php
$listingID = $_GET['listingID'];
$con = mysql_connect("localhost","****","********");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("auctionc_openr", $con);
$sql = "SELECT * FROM listing_expires WHERE (listing_id = '$listingID')";
// Define date format
$dateFormat = "Y-m-d H:i:s";
$targetDateDisplay = date($dateFormat,$targetDate);
$actualDateDisplay = date($dateFormat,$actualDate);
$result =mysql_query($sql);
$row = mysql_fetch_array($result);
// Define your target date here
$targetYear = $row['year'];
$targetMonth = $row['month'];
$targetDay = $row['days'];
$targetHour = 12;
$targetMinute = 00;
$targetSecond = 00;
// End target date definition
$targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
$actualDate = time();
$secondsDiff = $targetDate - $actualDate;
$remainingDay = floor($secondsDiff/60/60/24);
$remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
$remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
$remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
// Define date format
$dateFormat = "Y-m-d H:i:s";
$targetDateDisplay = date($dateFormat,$targetDate);
$actualDateDisplay = date($dateFormat,$actualDate);
?>
<br />
<font size="+1" color="#FF0000">Expires In: <?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?> </font> </p>
This works great but i need a dropdown box now which will have 3 selections in for 1 day, 1 week, 1 month.
When the user has selected one and submitted it will then enter a date 1 day, 7 days or 30 days from the current date into an SQl table.
Is this possible? or is there a better way around this?
Thanks
Ad.