Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. if($_SESSION['status_cadastro']):
  3. ?>
  4. <div class="notification is-success">
  5. <p>Cadastro efetuado!</p>
  6. <p>Faça login informando o seu usuário e senha <a href="login.php">aqui</a></p>
  7. </div>
  8. <?php
  9. endif;
  10. unset($_SESSION['status_cadastro']);
  11. ?>
  12.  
  13. <?php
  14. session_start();
  15. include("conexao.php");
  16.  
  17. $nome = mysqli_real_escape_string($conexao, trim($_POST['nome']));
  18. $usuario = mysqli_real_escape_string($conexao, trim($_POST['usuario']));
  19. $senha = mysqli_real_escape_string($conexao, trim(md5($_POST['senha'])));
  20.  
  21. $sql = "select count(*) as total from usuario_web where usuario = '$usuario'";
  22. $result = mysqli_query($conexao, $sql);
  23. $row = mysqli_fetch_assoc($result);
  24.  
  25. if($row['total'] == 1) {
  26. $_SESSION['usuario_existe'] = true;
  27. header('Location: cadastro.php');
  28. exit;
  29. }
  30.  
  31. $sql = "INSERT INTO usuario_web (nome, usuario, senha, data_cadastro) VALUES ('$nome', '$usuario', '$senha', NOW())";
  32.  
  33. if($conexao->query($sql) === TRUE) {
  34. $_SESSION['status_cadastro'] = true;
  35. }
  36.  
  37. $conexao->close();
  38.  
  39. header('Location: cadastro.php');
  40. exit;
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement