Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. signup class:
  2.  
  3. function __construct() {
  4. require 'db.php';
  5. $this->db = new db();
  6. }
  7. public function checkDuplicate($email) {
  8. $this->db->connect();
  9. $q = $this->db->conn->query("SELECT email FROM table WHERE email = $email");
  10.  
  11. return (($q->rowCount() > 0) ? true : false);
  12. }
  13.  
  14. db.php:
  15.  
  16. class db {
  17.  
  18. public function __construct() {
  19. $this->dsn = 'mysql:host=127.0.0.1;port=3306;dbname=fb';
  20. $this->user = 'root';
  21. $this->password = '';
  22. }
  23. public function connect(){
  24. try {
  25. $this->conn = new PDO($this->dsn, $this->user, $this->password);
  26. } catch (PDOException $e) {
  27. header('Location: /sdfa/signup.php?dbError');
  28. }
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement