Validating a coupon

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 25, 2011   (RSS)

Re: [jtedescojam] Validating a coupon

By Jason - October 25, 2011

Hi John,

You could add this check to the WHERE clause of you mysql_select_count_from() function.

For example:

// validate coupon code
if (!$errorsAndAlerts) {
$count = mysql_select_count_from('coupon_codes', "`code` = '".mysql_escape(@$_REQUEST['couponCode'])."' AND item_reference = '".mysql_escape($detailRecord['title'])."'");

if ($count > 0 && @$_REQUEST['couponCode']) {
$errorsAndAlerts .= "Your code has been validated! Please fill out the form below to process your order\n";
$showSignupForm = true;
}
else if(!$count > 0 && @$_REQUEST['couponCode']) {
$errorsAndAlerts .= "Your code is not valid! Please check the code and try again. If you feel you've gotten this message in error, please contact us.\n";
}

}


Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/