Guest User

Untitled

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $dbhost = '';
  4. $dbuser = '';
  5. $dbpass = '';
  6. $con=mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error Connection to MySQL');
  7. $dbname = 'a1059070_users';
  8. mysql_select_db($dbname);
  9.  
  10.  
  11. if($_POST['fun']=='signup')
  12. {
  13. $poke = new Homepage();
  14. $poke->signup();
  15. }
  16. else
  17. echo "Error in selecting function";
  18.  
  19.  
  20.  
  21. class Homepage
  22. {
  23. var $username;
  24. var $pass1;
  25. var $pass2;
  26. var $email;
  27. var $timezone;
  28. var $agree1;
  29. var $agree2;
  30. function __construct()
  31. {
  32. $this->username = $_POST['username'];
  33. $this->pass1 = $_POST['pass1'];
  34. $this->pass2 = $_POST['pass2'];
  35. $this->email = $_POST['email'];
  36. $this->timezone = $_POST['timezone'];
  37. $this->agree1 = $_POST['agree1'];
  38. $this->agree2 = $_POST['agree2'];
  39. }
  40. function signup()
  41. {
  42. if($this->pass1 == $this->pass2 && $this->agree1 == 'on' && $this->agree2 == 'on')
  43. {
  44. $check1 = mysql_query("SELECT username FROM `users` WHERE username='$this->username'");
  45. $check2 = mysql_num_rows($check1);
  46. if($check2 > 0)
  47. {
  48. echo "Error, username has already been taken.";
  49. }
  50. else
  51. {
  52. mysql_query("INSERT INTO `users` (username, password, email, timezone) VALUES ('$this->username', '$this->pass1', '$this->email', '$this->timezone')")or die(mysql_error());
  53. echo "You have successfully signed up.";
  54. }
  55. }
  56. else
  57. {
  58. echo "Error. Did you fill the form out fully, and check the check boxes?";
  59. }
  60. }
  61. }
  62. ?>
Add Comment
Please, Sign In to add comment