Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbserverprogrammering/projekt/snake_oil_seller/php/

about_us.php
add_to_cart.php
admin.php
buy_cart.php
config.php
contact.php
create_products.php
create_tables.php
createtable.php
dbconnection.php
delete_post.php
delete_tables.php
deletepost.php
deletetable.php
entry.php
header.php
insert_posts.php
insertposts.php
leaderboard.php
log_in.php
log_out.php
main.php
my_account.php
question_maker.php
quiz_form.php
quiz_list.php
quiz_maker.php
result.php
select_posts.php
selectposts.php
shop.php
shop_item.php
shopping_cart.php
sign_in.php
title_card.php
update_posts.php
updateposts.php
user_verified.php
verify_page.php

dbconnection.php

32 lines ASCII Windows (CRLF)
<!-- dbconnection.php -->
<?php
  
// $local = !isset($_SERVER["HTTP_HOST"]) || strpos($_SERVER["HTTP_HOST"], 'labb.vgy.se') === false;''
  
$local false;

  include 
'config.php';

  if (
$local) {
    
$dbname $db_name_local;
    
$hostname $db_hostname_local;
    $
/* DB_USER, is removed and hidden for security reasons */ ;
    $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
  } else {
    
$dbname $db_name_prod;
    
$hostname $db_hostname_prod;
    $
/* DB_USER, is removed and hidden for security reasons */ ;
    $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
  }
  
$options  = [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"];

  try {
      
$dbconn = new PDO("mysql:host=$hostname;dbname=$dbname", $/* DB_USER, is removed and hidden for security reasons */ ;
      
$dbconn->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
      
/*** echo a message saying we have connected ***/
      // echo "Database connection successful.<br />";
  
} catch(PDOException $e){
      
// For debug purpose, shows all connection details
      
echo 'Connection failed: '.$e->getMessage()."<br />";
        
// Hide connection details.
      //echo 'Could not connect to database.<br />'); 
  
}
?>