Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. var_dump($q);
  11.  
  12. //return (($q->rowCount() > 0) ? true : false);
  13. }
  14.  
  15. db.php:
  16.  
  17. class db {
  18.  
  19. public function __construct() {
  20. $this->dsn = 'mysql:host=127.0.0.1;port=3306;dbname=fb';
  21. $this->user = 'root';
  22. $this->password = '';
  23. }
  24. public function connect(){
  25. try {
  26. $this->conn = new PDO($this->dsn, $this->user, $this->password);
  27. } catch (PDOException $e) {
  28. header('Location: /sdfa/signup.php?dbError');
  29. }
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement