Advertisement
Guest User

auth.php

a guest
Mar 31st, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: root
  5. * Date: 31/03/16
  6. * Time: 00:38
  7. */
  8.  
  9. require "../ConfigDB/DBenv.php";
  10. class Auth
  11. {
  12.  
  13. private $username;
  14. private $password;
  15. private $email;
  16.  
  17.  
  18. /**
  19. *
  20. */
  21. public function register()
  22. {
  23. $this->username = $_POST['Username'];
  24. $this->password = $_POST['Password'];
  25. $this->email = $_POST['Email'];
  26.  
  27.  
  28. echo $this->username;
  29. echo $this->password;
  30. echo $this->email;
  31.  
  32. $this->username = mysql_real_escape_string($this->username);
  33. $this->password = mysql_real_escape_string($this->password);
  34. $mysql = "SELECT * FROM Users WHERE username = $this->username";
  35. $query = Mysql_query($mysql);
  36.  
  37. $count = mysql_num_rows($query);
  38.  
  39. if($count==0){
  40. echo "you can register";
  41. $this->insert();
  42.  
  43. }else{
  44.  
  45. echo"you are allready registerd";
  46. }
  47. }
  48.  
  49. public function insert(){
  50.  
  51. if(mysql_query("INSERT INTO Users ('Username', 'Password', 'Email')VALUES ('$this->username', '$this->password', '$this->email')")){
  52.  
  53. echo "registerd";
  54. }
  55. else
  56. {
  57.  
  58. echo "not registerd";
  59. }
  60. }
  61.  
  62. /*close class Auth*/
  63. }
  64.  
  65. $obj = new Auth();
  66.  
  67. var_dump($obj);
  68.  
  69. if(isset($_POST['Register']))
  70. {
  71. $obj->register();
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement