Advertisement
Guest User

Untitled

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