Want more features on Pastebin? Sign Up, it's FREE!
Guest

Weird

By: spp935 on May 3rd, 2012  |  syntax: PHP  |  size: 1.46 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /******************************************************
  4. *       Login class using PDO                                                     *
  5. ******************************************************/
  6.  
  7. class Login{
  8.  
  9.         private $pdo;
  10.  
  11.         public function __construct(PDO $pdo){
  12.                 $this->pdo = $pdo;
  13.  
  14.         }
  15.  
  16. //      public function loginAllowed($user, $pw){
  17. //
  18. //              $sth = $pdo->setFetchMode(PDO::FETCH_ASSOC);
  19. //              print_r($sth);
  20. //      }
  21. //
  22. //      public function runQuery($query, $params){
  23. //              $sth = $this->pdo->prepare($query);
  24. //              $sth->execute($params);
  25. //      }
  26.  
  27.  
  28. }
  29.  
  30.  
  31. $configFile = 'cbd.ini';
  32.  
  33.         $conn = parse_ini_file($configFile);
  34.  
  35.         $username = $conn['username'];
  36.         $password = $conn['password'];
  37.         $host = $conn['host'];
  38.         $database = $conn['database'];
  39.         $driver = $conn['driver'];
  40.  
  41.         try{
  42.                 $pdo = new PDO("$driver:host=$host;dbname=$database", $username, $password);
  43.         }
  44.         catch(PDOException $e){
  45.                 header ("Location:../suiteCrm/errorPages/databaseError.html");
  46.         }
  47.  
  48.  
  49.         $configFile = 'cbd.ini';   //just has the db connection details
  50.  
  51.         $conn = parse_ini_file($configFile);
  52.  
  53.         $username = $conn['username'];
  54.         $password = $conn['password'];
  55.         $host = $conn['host'];
  56.         $database = $conn['database'];
  57.         $driver = $conn['driver'];
  58.  
  59.         try{
  60.                 $pdo = new PDO("$driver:host=$host;dbname=$database", $username, $password);
  61.         }
  62.         catch(PDOException $e){
  63.                 header ("Location:../suiteCrm/errorPages/databaseError.html");
  64.         }
  65.  
  66.  
  67.  
  68. try {
  69.         $login = new Login($pdo);
  70. } catch (Exception $e) {
  71.         echo $e->getMessage();
  72. }
clone this paste RAW Paste Data