Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement