SHARE
TWEET

Untitled

a guest Jun 15th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //FORM DE REGISTRO
  2. <html>
  3. <head>
  4. <title> Cadastro de Usuário </title>
  5. </head>
  6. <body>
  7. <form method="POST" action="cadastro.php">
  8. <label>Login:</label><input type="text" name="login" id="login"><br>
  9. <label>Senha:</label><input type="password" name="senha" id="senha"><br>
  10. <input type="submit" value="Cadastrar" id="cadastrar" name="cadastrar">
  11. </form>
  12. </body>
  13. </html>
  14.  
  15. //CADASTRO.PHP
  16. <?php
  17.  
  18.  
  19. $login = $_POST['login'];
  20. $senha = MD5($_POST['senha']);
  21. $connect = mysql_connect('localhost','NOMEDOUSER','SENHA');
  22. $db = mysql_select_db('DBNAME');
  23. $query_select = "SELECT login FROM usuarios WHERE login = '$login'";
  24. $select = mysql_query($query_select,$connect);
  25. $array = mysql_fetch_array($select);
  26. $logarray = $array['login'];
  27.  
  28.   if($login == "" || $login == null){
  29.     echo"<script language='javascript' type='text/javascript'>
  30.     alert('O campo login deve ser preenchido');window.location.href='
  31.     cadastro.html';</script>";
  32.  
  33.     }else{
  34.       if($logarray == $login){
  35.  
  36.         echo"<script language='javascript' type='text/javascript'>
  37.         alert('Esse login já existe');window.location.href='
  38.         cadastro.html';</script>";
  39.         die();
  40.  
  41.       }else{
  42.         $query = "INSERT INTO usuarios (login,senha) VALUES ('$login','$senha')";
  43.         $insert = mysql_query($query,$connect);
  44.          
  45.         if($insert){
  46.           echo"<script language='javascript' type='text/javascript'>
  47.           alert('Usuário cadastrado com sucesso!');window.location.
  48.           href='login.html'</script>";
  49.         }else{
  50.           echo"<script language='javascript' type='text/javascript'>
  51.           alert('Não foi possível cadastrar esse usuário');window.location
  52.           .href='cadastro.html'</script>";
  53.         }
  54.       }
  55.     }
  56. ?>
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top