Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.     require_once'conn.php';
  3.     if(ISSET($_POST['use'])){
  4.         $coupon=$_POST['coupon'];
  5.        
  6.         $query=mysqli_query($conn, "SELECT * FROM `coupon` WHERE `coupon_code`='$coupon'") or die(mysqli_error());
  7.         $row=mysqli_num_rows($query);
  8.         $fetch=mysqli_fetch_array($query);
  9.         if($row > 0){
  10.             if($fetch['status']==''){
  11.                 echo "<div class='alert alert-info'>Coupon code activated!</div>";
  12.                 mysqli_query($conn, "UPDATE `coupon` SET `status`='used' WHERE `coupon_id`='$fetch[coupon_id]'") or die(mysqli_error());
  13.             }else{
  14.                 echo "<div class='alert alert-danger'>Your coupon code has been used!</div>";
  15.             }
  16.         }else{
  17.             echo "<div class='alert alert-danger'>Your coupon code is not available!</div>";
  18.         }
  19.     }
  20. ?>