The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Please help convert into array
Discuss Please help convert into array in the PHP Development forum on Dev Shed. Please help convert into array PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 3rd, 2012, 03:47 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 4
Time spent in forums: 1 h 9 m 7 sec
Reputation Power: 0
|
|
|
Please help convert into array
PHP Code:
<?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;
}
?>
I need to add 10/03/12, 10/04/12, 10/05/12, 10/06/12, 10/07/12, 10/08/12, 10/09/12, 10/10/12 to an array
and then check if coupon code = 10off and $_POST['date'] = one of the dates above.
I know I need to convert it into an array but I can't figure out how even after researching.
Can someone please help me out with this?
Thank you for the help.
|

October 3rd, 2012, 03:52 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
Is the coupon going to be valid on the 14th of this month? How about in November? Next year?
|

October 3rd, 2012, 04:21 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 4
Time spent in forums: 1 h 9 m 7 sec
Reputation Power: 0
|
|
|
Should only be good until october 10 2012
|

October 3rd, 2012, 04:22 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 4
Time spent in forums: 1 h 9 m 7 sec
Reputation Power: 0
|
|
|
So basically, if the "date" post is between today and October 10, 2012 ... continue on but if not then die;
|

October 3rd, 2012, 05:14 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by activetech84 So basically, if the "date" post is between today and October 10, 2012 ... continue on but if not then die; |
Or more simply "if it's after October 10, 2012".
But before I go to the easy solution, why are you getting the date from $_POST? Don't you want to use today's date?
[edit] I may have misread a bit but still the underlying issue stands: can't someone just enter whatever valid date they want and get access?
Last edited by requinix : October 3rd, 2012 at 05:51 PM.
|

October 3rd, 2012, 05:48 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 4
Time spent in forums: 1 h 9 m 7 sec
Reputation Power: 0
|
|
|
this is used for appointments. on the previous step the user chooses a date for the appointment and uses the coupon to get a discount but it must be scheduled on an allowed date.
|

October 3rd, 2012, 05:59 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
I actually just realized that there are, in fact, three different dates in play. Right? I still think you can just go with a "if it's before October 10" (because they can't make an appointment in the past).
But anyway no, then, they can't put in arbitrary dates. You can compare dates really easily if you convert them into YYYY/MM/DD format (because MM/DD/YY doesn't work). For example,
PHP Code:
if (date("Y/m/d") > "2012/10/13") { // if today is after Oct 13th
|

October 4th, 2012, 04:02 AM
|
|
Permanently Banned
|
|
Join Date: Oct 2012
Posts: 8
Time spent in forums: 59 m 49 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
|
|
|
Please help convert into array
Thanks for joining with me and also fine this forum.Really nice foru thanks for share this...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|