<?php
include "conexao.php";
require('bcrypt.php');

$nome = $_POST['nome'];
$sobrenome = $_POST['sobrenome'];
$email = $_POST['email'];
$senha = Bcrypt::hash($_POST['senha']);
$limite_assinatura = implode("-",array_reverse(explode("/",$_POST['limite_assinatura'])));

$insert_query = "INSERT into usuarios (nome, sobrenome, email, senha, limite_assinatura, created_at) VALUES ('$nome', '$sobrenome', '$email', '$senha', '$limite_assinatura', '".date('Y-m-d H:i:s')."')";
$insert = $sqli->query($insert_query);

/*
$debug_arr = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
header('Content-Type: text/plain');
print_r(array('GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER, 'INSERT QUERY' => $insert_query, 'INSERT RESULT' => $insert));
echo $insert;
print_r($debug_arr);
exit;
*/

echo "<script> alert('Usuario cadastrado com sucesso'); window.location.href = 'usuarios.php'; </script>";

?>