Need help converting to array

General discussions related to php

Moderators: macek, egami, gesf

Post Reply
cpcdev
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Jun 03, 2011 3:38 pm

Need help converting to array

Post by cpcdev » Wed Oct 03, 2012 1:37 pm

Hello,

I need help writing an if statement that checks if coupon code = "10off" and $_POST['date'] = any date between today and October 10, 2012.

Basically, if it's a date outside of that range it will say "The 10% coupon must be redeemed by Wednesday October 10, 2012. Please go back and choose an allowed date."

I've tried researching arrays but can't figure out how to do this. Would someone mind helping me out?

Thank you :D

Code: Select all

<?php  
if (($_POST['couponcode'] == "10off") && ($_POST['date'] !== "10/03/12" )) { 
echo "The 10% coupon must be redeemed by Wednesday October 10, 2012. Please go back and choose an allowed date."; 
die; 
} 
?>

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Need help converting to array

Post by egami » Thu Oct 04, 2012 8:18 am

Code: Select all


$today     = date('U'); // Right Now in Epoc Seconds
$expires   = strtotime($_POST['date']); // expired date in EPOC seconds
$code       = trim(strip_tags($_POST['couponcode']));


if ($today < $expires)
{
  echo "Yay. You can buy it today!";
} else { 
  echo "Ooops.. Sorry, you missed the expiration date.";
}
 

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests