<?php
session_start();
require_once 'connect.php';
$username = $_POST['username'];
$password = hash('haval256,5', $_POST['password']);
$password_confirm = hash('haval256,5', $_POST['password_conf']);
$email = $_POST['email'];
$profile_image = $_FILES['avatar']['tmp_name'];
if($password != $password_confirm){
$_SESSION['message'] = 'Пароли не совпадают!';
header('Location: ../register.php');
}else{
// ok...
}
if($username == "" || $password == ""){
$_SESSION['message'] = 'Заполните все поля!';
header('Location: ../register.php');
}else{
$check_user = mysqli_query($connect, "SELECT * FROM `users` WHERE `username` = '$username'");
if(mysqli_num_rows($check_user) == 1){
$_SESSION['message'] = 'Этот ник уже занят!';
header('Location: ../register.php');
}else{
$rand1 = "avatars/".rand(1000000000, 9999999999).".png";
move_uploaded_file($profile_image, "../".$rand1);
// Проблемный скрипт <<<<<<<<
$create_table = mysqli_query($connect, "INSERT INTO `users`(`id`, `username`, `email`, `password`, `plan`, `banned`, `avatar`, `subscribers`, `status`, `used_plan`) VALUES (NULL, '$username', '$email', '$password', 3, 'no', '$rand1', 0, 'surfer', 3)");
$_SESSION['message'] = 'Регистрация прошла успешно';
}
}
?>