Advertisement
gayanov

Untitled

Feb 23rd, 2017
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.68 KB | None | 0 0
  1. <?php
  2.  
  3. /** include "../config.php";
  4. include "connect.php";
  5. if (isset($_POST['group']) && isset($_POST['nickname'])) {
  6. $mysqli = new mysqli($settings["db"]["host"], $settings["db"]["user"], $settings["db"]["password"], $settings["db"]["dbname"]);
  7. $roupprice = $mysqli->query("SELECT * FROM `groups` WHERE `name` = '".$_POST['group']."' ORDER BY sum DESC LIMIT 1", MYSQLI_USE_RESULT);
  8. $grouppriceon = mysqli_fetch_assoc($groupprice)['sum'];
  9. $toPay = $grouppriceon;
  10.  
  11. if (isset($_POST['promo']) && $_POST['promo'] != "") {
  12.     if (array_key_exists($_POST['promo'], $options['promo'])) {
  13.         $coupon = $_POST['promo'];
  14.         $discount = $options['promo'][$_POST['promo']];
  15.             $toPay = $toPay - ($toPay / 100 * $discount);
  16.     }
  17. }
  18.    
  19.  
  20. $result = $mysqli->query("SELECT * FROM `doplata` WHERE `nickname` = '".$_POST['nickname']."' AND `buy` = '".$_POST['group']."' ORDER BY money DESC LIMIT 1", MYSQLI_USE_RESULT);
  21. $base_money = mysqli_fetch_assoc($result)['money'];
  22. if ($toPay > $base_money) $toPay = $toPay - $base_money;
  23.  
  24.         if($toPay <= $base_money) {
  25.             echo '<a class="btn btn-danger btn-block disabled">Вы не можете купить данную привилегию</a>';
  26.         } else {
  27.             echo '<button type="submit" class="btn btn-primary btn-block">Купить за '.$toPay.' рублей</button>';
  28.         }
  29. }
  30.  
  31.  
  32.  *   CREATE TABLE `test` (
  33.  *    `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  34.  *    `login` VARCHAR(50) NOT NULL,
  35.  *    `password` VARCHAR(50) NOT NULL,
  36.  *    `email` VARCHAR(130) NULL DEFAULT NULL,
  37.  *    `ip` VARCHAR(50) NULL DEFAULT NULL,
  38.  *    `lastlogin` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
  39.  *    `activation` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
  40.  *      PRIMARY KEY (`id`),
  41.  *      INDEX `login` (`login`)
  42.  *   ) ENGINE=MyISAM;
  43.  */
  44.    //session_start();
  45.   include "../config.php";
  46.  
  47. if (isset($_POST['group']) && isset($_POST['nickname']))
  48. {
  49.  
  50.    $param = $db->prepare('SELECT * from groups WHERE `name` = ?');
  51.  
  52.    $param->bindParam(1, $_POST['group'], PDO::PARAM_STR);
  53.  
  54.    if ($param->execute())
  55.    {
  56.       $param->setFetchMode(PDO::FETCH_ASSOC);
  57.      
  58.       if ($result = $param->fetchAll())
  59.       {
  60.          // Станет доступно
  61.          // $result[0]['id'];
  62.          // $result[0]['login'];
  63.          // $result[0]['password'];
  64.          // $result[0]['email'];
  65.          // $result[0]['ip'];
  66.          // $result[0]['lastlogin'];
  67.          // $result[0]['activation'];
  68.       echo $result[0]['sum'];
  69.       echo $result[0]['name'];
  70.       }
  71.    }
  72.  // if($_POST['login'] == $result[0]['login'] && $_POST['login'] == $result[0]['password']) {    
  73.    //   exit('<script>
  74.     //  toastr.success("ok")</script>');
  75.   //}
  76.    
  77. }
  78. else echo "error";
  79.  
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement