Guest User

Untitled

a guest
Jan 5th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php
  2.  
  3. $host = "localhost"; // your sql instance
  4. $user = "root"; // username
  5. $pw = ""; // password
  6. $db = "bananachat"; // db
  7.  
  8. $connect = mysql_connect($host, $user, $pw)
  9. or die("Can't connect to the datebase.");
  10.  
  11. mysql_select_db($db,$connect)
  12. or die("Can't select the datebase");
  13.  
  14. ?>
  15.  
  16. <html>
  17. <head>
  18. <title>Register</title>
  19. <center>
  20. <h3 style="color:red">Register Page</h3>
  21. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  22. Username : <input type="text" size="20" name="name" /><br />
  23. Password : <input type="password" size="20" name="password" /><br /><br />
  24. <input type="submit" value="Register now !" name="senden" />
  25. </form>
  26. <?php
  27. if (isset($_POST['senden'])) {
  28. $usr = $_POST['name'];
  29. $pass = $_POST['password'];
  30. $pw = sha1($pass);
  31.  
  32. $results = mysql_query("SELECT * FROM accounts WHERE name = '".$usr."'");
  33. $res = mysql_num_rows($results);
  34. if(strlen($usr) >= 4 && strlen($pass) >= 4)
  35. {
  36. if($res > 0)
  37. {
  38. echo "Dieser Accounts ist bereits vergeben.";
  39. }
  40. else
  41. {
  42. mysql_query("INSERT INTO accounts set name='".$usr."', password='".$pw."'");
  43. echo "Du hast soeben den Nicknamen ".$usr." registriert.";
  44. }
  45. }
  46. else
  47. {
  48. echo "Nickname oder Passwort sind zu kurz...";
  49. }
  50. }
  51. ?>
  52. </center>
  53. </head>
  54. </html>
Add Comment
Please, Sign In to add comment