Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ob_start();
- require_once 'block/conf.php';
- class USER {
- public $login;
- public $password;
- public $data;
- global $pdo;
- function check_user($login,$password)
- {
- $this->login = $login;
- $this->password = $password;
- $stmt = $pdo->prepare("SELECT * FROM users WHERE login = :login");
- $stmt->bindParam(":login",login);
- if($stmt->execute())
- {
- while($row = $stmt->fetch(PDO::FETCH_LAZY))
- {
- $bd_login = $row['login'];
- $bd_password = $row['pass'];
- if(password == $bd_password)
- return 0;
- else
- return 1;
- }
- }else
- header("Location:404.php");
- }
- function reg_new_user($login,$password,$data,$nickname)
- {
- $this->login = $login;
- $this->password = $password;
- $this->data = $data;
- $this->nickname = $nickname;
- $stmt = $pdo->prepare("INSERT INTO users (login, pass,regdate,nickname) VALUES (:login,:pass,:regdate,:nickname)");
- $stmt->bindParam(':login', login);
- $stmt->bindParam(':pass', password);
- $stmt->bindParam(':regdate', data);
- $stmt->bindParam(':nickname', nickname);
- if($stmt->execute())
- return 0;
- else
- return 1;
- }
- }
- if(isset($_POST['reg']))
- {
- $user = new USER;
- if($user->check_user($_POST['login'],$_POST['password']) == 1)
- {
- if($user->reg_new_user($_POST['login'],$_POST['password'],$start = date('M-d H:i', time() + 10800),$_POST['nickname']) == 0)
- {
- $_SESSION['check'] = true;
- $_SESSION['name'] = $nickname;
- header("location:vce.php");
- }else
- header("Location:404.php");
- }else
- echo "<script>alert('Пользователь уже зарегестрирован');</script>";
- }
- ob_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement