$query = "INSERT INTO users SET login = '$login', name = '$name', email =
$email', pass = '$pass', status = 'user'";
mysqli_query($link, $query) or die (mysqli_error($link));
$_SESSION['auth'] = true;
$query = "SELECT * FROM users WHERE login = '$login'";
mysqli_query($link, $query) or die (mysqli_error($link));
$user = mysqli_fetch_assoc(mysqli_query($link, $query));
$_SESSION['id'] = $user['id'];
$_SESSION['login'] = $user['login'];
$_SESSION['status'] = $user['status'];
$_SESSION['message_reg'] = "Регистрация успешно завершена";
header('Location: index.php?reg=ok');
$query = "INSERT INTO users SET login = ?, name = ?, email = ?, pass = ?, status = 'user'";
$stmt = $link->prepare($query);
$stmt->bind_param("ssss",$login,$name,$email,$pass);
$stmt->execute();