2017-04-22 55 views
-1

我有一个形式,PHP,如果用户把正确的优惠券代码类似的东西定义为:

$ret['status'] = 'success'; 

和明年是:

if($ret['status'] == 'success'){ 
         $ret['coupon-id'] = $query->post_id; 
         $ret['amount'] = $post_option['coupon-discount-amount']; 
         $ret['type'] = $post_option['coupon-discount-type']; 



         $discount_text = ''; 
         if($ret['type'] == 'percent'){ 
          $discount_text = $post_option['coupon-discount-amount'] . '%'; 

         }else{ 
          $discount_text = gdlr_lms_money_format($post_option['coupon-discount-amount']); 
         } 
         $ret['message'] = sprintf(__('You got %s discount', 'gdlr-lms'), $discount_text);       
        } 

和窗体的底部都有一个带这个条件提交按钮:

if(empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email'])){ 
       $ret['status'] = 'failed'; 
       $ret['message'] = __('Please fill all required fields.', 'gdlr-lms'); 

我需要添加到这个条件是正确的优惠券也是必需的。我需要添加到此代码才能完成它?我一直在寻找5个小时的答案,我尝试了所有我找到的东西,但没有任何工作 - 请帮助我! :)

这是带表格的网站 - 注册表格后会有我询问的课程报名表格。

http://semcamp.university/course/starting-company-all-you-need-to-know-to-start-company-2-2-2-2/

您可以使用用户名登录:计算器和密码:栈1和有效copuon代码为1234或test1的

回答

0

你的问题是不是在这非常清楚,如果语句应的优惠券进行验证。但是,假定它需要在最后一节(中频提交按钮)进行验证,你可以这样做的:

if(empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email'])){ 
    $ret['status'] = 'failed'; 
    $ret['message'] = __('Please fill all required fields.', 'gdlr-lms'); 
} 
elseif($ret['status'] != 'success') { 
    $ret['status'] = 'failed'; 
    $ret['message'] = __('Please provide a valid coupon.', 'gdlr-lms'); 
} 
+0

谢谢你,但taht不起作用。更清楚的是,这是验证网站:[http://semcamp.university/course/starting-company-all-you-need-to-know-to-start-company-2-2-2-2/ ],我不知道与你分享洞码吗?但现在它看起来不知道是否有'$ ret ['status] ='sucecess'' –

+0

您可以使用用户名登录:stackoverflow和密码:stack1和有效的copun是1234或test1 –