SHARE
TWEET

Untitled

a guest Jan 19th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. include("includes/conexao.php");
  4.  
  5. $nome = mysqli_real_escape_string($conexao, trim($_POST['nome']));
  6. $usuario = mysqli_real_escape_string($conexao, trim($_POST['usuario']));
  7. $senha = mysqli_real_escape_string($conexao, trim(md5($_POST['senha'])));
  8.  
  9. $sql = "select count(*) as total from usuario where usuario = '$usuario'";
  10. $result = mysqli_query($conexao, $sql);
  11. $row = mysqli_fetch_assoc($result);
  12.  
  13. if($row['total'] == 1) {
  14.     $_SESSION['usuario_existe'] = true;
  15.     header('Location: cadastro.php?status=error');
  16.     exit;
  17. }
  18.  
  19. $sql = "INSERT INTO usuario (nome, usuario, senha, data_cadastro) VALUES ('$nome', '$usuario', '$senha', NOW())";
  20.  
  21. if($conexao->query($sql) === TRUE) {
  22.     $_SESSION['status_cadastro'] = true;
  23. }
  24.  
  25. $conexao->close();
  26.  
  27. header('Location: cadastro.php?status=success');
  28. exit;
  29. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top