Advertisement
gayanov

Untitled

Feb 26th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.36 KB | None | 0 0
  1. <?php
  2. /**
  3.  *   CREATE TABLE `test` (
  4.  *    `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  5.  *    `login` VARCHAR(50) NOT NULL,
  6.  *    `password` VARCHAR(50) NOT NULL,
  7.  *    `email` VARCHAR(130) NULL DEFAULT NULL,
  8.  *    `ip` VARCHAR(50) NULL DEFAULT NULL,
  9.  *    `lastlogin` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
  10.  *    `activation` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
  11.  *      PRIMARY KEY (`id`),
  12.  *      INDEX `login` (`login`)
  13.  *   ) ENGINE=MyISAM;
  14. if(isset($_GET['group']))   {
  15. //Часть с никнейном
  16.    $param1 = $db->prepare('SELECT * from groups WHERE `name` = ?');
  17.  
  18.    $param1->bindParam(1, $_GET['group'], PDO::PARAM_STR);
  19.  
  20.    if ($param1->execute())
  21.    {
  22.       $param1->setFetchMode(PDO::FETCH_ASSOC);
  23.      
  24.       if ($result1 = $param1->fetchAll())
  25.       {
  26.          // Станет доступно
  27.          // $result[0]['id'];
  28.          // $result[0]['login'];
  29.          // $result[0]['password'];
  30.          // $result[0]['email'];
  31.          // $result[0]['ip'];
  32.          // $result[0]['lastlogin'];
  33.          // $result[0]['activation'];
  34.       $toPay = $result1[0]['sum'];
  35.       echo $toPay;
  36.       }
  37.  
  38.    }
  39. }
  40.  */
  41.    //session_start();
  42.   include "../config.php";
  43.  
  44.  
  45.  
  46. if ( ! empty($_POST['login']) AND ! empty($_POST['password']))
  47. {
  48.    $param = $db->prepare('SELECT * from `users` WHERE `login` = ? AND `password` = ? AND `activation` = 1;');
  49.  
  50.    if ( ! $param->bindParam(1, $_POST['login'], PDO::PARAM_STR, 50))
  51.    {
  52.       exit('<script>
  53.         toastr.error("Слишком длиный логин!")</script>');
  54.    }
  55.    elseif ( ! $param->bindParam(2, $_POST['password'], PDO::PARAM_STR, 50))
  56.    {
  57.       exit('<script>
  58.         toastr.error("Слишком длиный пароль!")</script>');
  59.    }
  60.  
  61.    if ($param->execute())
  62.    {
  63.       $param->setFetchMode(PDO::FETCH_ASSOC);
  64.      
  65.       if ($result = $param->fetchAll())
  66.       {
  67.          // Станет доступно
  68.          // $result[0]['id'];
  69.          // $result[0]['login'];
  70.          // $result[0]['password'];
  71.          // $result[0]['email'];
  72.          // $result[0]['ip'];
  73.          // $result[0]['lastlogin'];
  74.          // $result[0]['activation'];
  75.          //$has_pass = hash_hmac('sha256', 'wefffewewf', 'ewfewewew');
  76.            $param1 = $db->prepare('UPDATE users SET `login` = ?');
  77. //UPDATE
  78.    $param1->bindParam(1, $_POST['login'], PDO::PARAM_STR);
  79.  
  80.    if ($param1->execute())
  81.    {
  82.       $param1->setFetchMode(PDO::FETCH_ASSOC);
  83.      
  84.       if ($result1 = $param1->fetchAll())
  85.       {
  86.          // Станет доступно
  87.          // $result[0]['id'];
  88.          // $result[0]['login'];
  89.          // $result[0]['password'];
  90.          // $result[0]['email'];
  91.          // $result[0]['ip'];
  92.          // $result[0]['lastlogin'];
  93.          // $result[0]['activation'];
  94.       echo $result1[0]['id'];
  95.       //echo $result[0]['name'];
  96.       }
  97.  
  98.    }
  99.       exit('<script>
  100.         toastr.success("'.$has_pass.'")</script>');
  101.       }
  102.       else exit ('<script>
  103.         toastr.error("Нету такого пользователя или ваша учётная запись ещё не активирована!")</script>');
  104.    }
  105.  // if($_POST['login'] == $result[0]['login'] && $_POST['login'] == $result[0]['password']) {    
  106.    //   exit('<script>
  107.     //  toastr.success("ok")</script>');
  108.   //}
  109.    
  110. }
  111. else exit ('<script>
  112.         toastr.error("Заполните все поля!")</script>');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement