abch624 Posted March 29, 2009 Share Posted March 29, 2009 I am comparing two fields during payment $startdate // This will be MMYY $expirydate // This will be MMYY I want to make sure that $startdate is smaller than $expirydate.... Any help will be nice with this:) Thanks - Zahid Quote Link to comment https://forums.phpfreaks.com/topic/151568-solved-compare-two-mmyy-type-fields/ Share on other sites More sharing options...
Salkcin Posted March 29, 2009 Share Posted March 29, 2009 ex, <?php // date in MMYY $startdate = '0328'; $expirydate = '0409'; if ((int)$startdate < (int)$expirydate) { echo "Great! Startdate is smaller than expirydate"; } else { echo "Error! Startdate can't be greater than expirydate"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151568-solved-compare-two-mmyy-type-fields/#findComment-796050 Share on other sites More sharing options...
abch624 Posted March 29, 2009 Author Share Posted March 29, 2009 Hi There, This will work partially but is not the best way. I coded this: $startyear = substr($startdate, 2,4); $startmonth = substr($startdate, 0,1); $expiryyear = substr($expirydate, 2,4); $expirymonth = substr($expirydate, 0,1); if ($expiryyear < $startyear) { $errors .= '#Please provide correct expiry and start date for the card details. '; } if ($expiryyear == $startyear) { if ($expirymonth == $startmonth) { $errors .= '#Please provide correct expiry and start date for the card details. '; } } Quote Link to comment https://forums.phpfreaks.com/topic/151568-solved-compare-two-mmyy-type-fields/#findComment-796052 Share on other sites More sharing options...
redarrow Posted March 29, 2009 Share Posted March 29, 2009 sorry had to say some think, in the uk it a crime to keep user's credit card information in a database due to id theft. it also a very big headache if the user get the card used not via them, usually all web sites get police investigated for fraud. i strongly suggest you use a payment gate way, to take payments, any information sent to you from the payment gateway, is there responsibility of sending it, they wont send credit card info, but will send all important references about the current payment. pay pal is a very good payment gateway and Google well known and very secure. if you have set up a payment gate way with a bank or business then there integration rules should apply. once again don't hold user's payment credit cards, it can lead to long investigations. also on the plus sign using a secure well known gateway will encourage sales. Quote Link to comment https://forums.phpfreaks.com/topic/151568-solved-compare-two-mmyy-type-fields/#findComment-796173 Share on other sites More sharing options...
redarrow Posted March 29, 2009 Share Posted March 29, 2009 There are down sides to using payment gate ways as well. if you want to no them down sides even more then i am willing to tell you. Quote Link to comment https://forums.phpfreaks.com/topic/151568-solved-compare-two-mmyy-type-fields/#findComment-796177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.