Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <html>
  2. <head></head>
  3. <title>Painel de Controle - Registro</title>
  4. <body>
  5. <h2>Painel de Controle - Registro</h2>
  6.  
  7. <?php
  8. if (!isset($_POST['nickname'])) $_POST['nickname'] = "unknown";
  9. if (!isset($_POST['password'])) $_POST['password'] = "unknown";
  10. if (!isset($_POST['cpassword'])) $_POST['cpassword'] = "unknown";
  11. if (!isset($_POST['email'])) $_POST['email'] = "unknown@unknown.com";
  12.  
  13. $nickname = $_POST['nickname'];
  14. $password = $_POST['password'];
  15. $cpassword = $_POST['cpassword'];
  16. $hash;
  17. $email = $_POST['email'];
  18.  
  19. $server = '127.0.0.1';
  20. $dbusername="root";
  21. $dbpassword="Pu2A9paUuMBnZy3Z";
  22. $database="cpanel";
  23. $query;
  24. $result;
  25.  
  26. if (!isset($_POST["submit"])) {
  27.  
  28. ?>
  29.  
  30. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  31.  
  32. Apelido: <br /><input type="text" size="12" maxlength="12" name="nickname"><br /><br />
  33. Senha: <br /><input type="password" size="12" maxlength="36" name="password"><br /><br />
  34. Confirme a senha: <br /><input type="password" size="12" maxlength="36" name="cpassword"><br /><br />
  35. Endereço de e-mail: <br /><input type="text" size="48" maxlength="48" name="email"><br /><br />
  36.  
  37. <input type="submit" value="Submit" name ="submit">
  38. </form>
  39. <?php
  40. } else {
  41. mysql_connect($server,$dbusername,$dbpassword);
  42. @mysql_select_db($database) or die("Naõ é possível conectar-se ao banco de dados.");
  43.  
  44. //check if user exists
  45. $query = mysql_query("SELECT * FROM users WHERE username = '$nickname'") or die(mysql_error());
  46. $result = mysql_fetch_array($query);
  47.  
  48. if (empty($_POST['nickname']) || empty($_POST['password']) || empty($_POST['cpassword']) || empty($_POST['email'])) {
  49. echo '<font color="red">Ocorreu um erro durante o registro!</font>';
  50. echo "<br />";
  51. echo "Você deixou um campo em branco.";
  52. }
  53.  
  54. elseif ($password != $cpassword) {
  55. echo '<font color="red">Ocorreu um erro durante o registro!</font>';
  56. echo "<br />";
  57. echo "As duas senhas não conferem.";
  58. }
  59.  
  60. elseif ($query && mysql_num_rows($result)>0)
  61. {
  62. echo '<font color="red">Ocorreu um erro durante o registro!</font>';
  63. echo "<br />";
  64. echo "Já existe um usuário de mesmo nome.";
  65. }
  66.  
  67. //e-mail already used
  68. else {
  69. echo '<font color="green">Registro efetuado com sucesso!</font>';
  70. echo "<br />";
  71. echo "Seja bem-vindo à nossa comunidade. Você já pode se logar.";
  72. $hash = hash("haval160,4",$password);
  73. $query = "INSERT INTO users VALUES('','$nickname','$hash','$email')";
  74. mysql_query($query);
  75. }
  76. mysql_close();
  77. }
  78. ?>
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement