Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. print '<title>Registration</title>';
  3. $name = $_POST['name'];
  4. $pass = $_POST['pass'];
  5.  
  6.  
  7. $host['naam'] = 'localhost'; // my host
  8. $host['gebruikersnaam'] = 'root'; // my database username
  9. $host['wachtwoord'] = ''; // my database password
  10. $host['databasenaam'] = 'testtest'; // my database name
  11.  
  12. $db = mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die ('Cant connect to the database');
  13. mysql_select_db($host['databasenaam'], $db);
  14.  
  15. $sel = 'SELECT * FROM users WHERE username="'.$_POST['name'].'"';
  16. if($name == ""){
  17. echo 'No username filled in';
  18. exit();
  19. }elseif(mysql_num_rows(mysql_query($sel)) >= 1 ){
  20. echo 'This username does already exists!';
  21. exit();
  22. }elseif($pass == ""){
  23. echo 'No password filled in';
  24. exit();
  25. }else{
  26. $encrypting = md5($pass);
  27. $d = 'INSERT INTO users (username, password) VALUES ("'.$name.'", "'.$encrypting.'")';
  28. mysql_query($d) OR die (mysql_error());
  29. echo 'Your account has been created, you can now login.';
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement