Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. include 'inc/header.php';
  3. if(strlen($_GET['view']) < 1) {
  4.     include 'views/default.php';
  5. } else {
  6.     if(file_exists('views/'. $_GET['view'] . '.php'))
  7.         include 'views/'. $_GET['view'] .'.php';
  8.        
  9.     /*** mysql hostname ***/
  10.     $hostname = 'localhost';
  11.    
  12.     /*** mysql username ***/
  13.     $username = 'root';
  14.    
  15.     /*** mysql password ***/
  16.     $password = 'password';
  17.    
  18.     try {
  19.         $dbh = new PDO("mysql:host=$hostname;dbname=mysql", $username, $password);
  20.         /*** echo a message saying we have connected ***/
  21.         echo 'Connected to database';
  22.         }
  23.     catch(PDOException $e)
  24.         {
  25.         echo $e->getMessage();
  26.         }
  27.    
  28.     else
  29.         include 'views/default.php';
  30. }    
  31. include 'inc/footer.php';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement