65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
session_start();
|
|
require 'db_connection.php';
|
|
?>
|
|
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
<h1>PHP Test Page</h1>
|
|
|
|
<h2>MySQL</h2>
|
|
|
|
<h3>Creating and Executing Query</h3>
|
|
<?php
|
|
try{
|
|
echo '<pre>';
|
|
echo "messageID\tdate\t\tsender\trecipient\tmessage\n\n";
|
|
$sql_select = "SELECT messageID, date, sender, recipient, message";
|
|
$sql_from = "FROM messages";
|
|
$sql_where = "WHERE recipient='".$_SESSION["loggedInUser"]."' OR sender='".$_SESSION["loggedInUser"]."'";
|
|
$sql_order = "ORDER BY messageID";
|
|
$sql_statement = $sql_select." ".$sql_from." ".$sql_where." ".$sql_order;
|
|
foreach($db_connection->query($sql_statement) as $row){
|
|
print $row['messageID']."\t\t";
|
|
print $row['date']."\t";
|
|
print $row['sender']."\t";
|
|
print $row['recipient']."\t\t";
|
|
print $row['message']."\n";
|
|
}
|
|
echo '</pre>';
|
|
}catch(PDOException $e){
|
|
echo "PDOException: ".$e->getMessage().PHP_EOL;
|
|
}catch(Exception $e){
|
|
echo "Exception: ".$e->getMessage().PHP_EOL;
|
|
}
|
|
|
|
echo '<h1>Variables</h1>';
|
|
|
|
echo '<h3>$sql</h3>';
|
|
echo "<pre>";
|
|
print_r($sql);
|
|
echo "</pre>";
|
|
|
|
$superglobalsList = array('$_SERVER','$_REQUEST','$_POST','$_GET','$_FILES','$_ENV','$_COOKIE','$_SESSION');
|
|
foreach($superglobalsList as $value){
|
|
echo "<h3>$value</h3>";
|
|
echo '<pre>';
|
|
print_r(eval('return '.$value.';'));
|
|
echo '</pre>';
|
|
}
|
|
|
|
echo '<h2> Like, everything everything?...</h2>';
|
|
echo '<h3>$GLOBALS</h3>';
|
|
echo "<pre>";
|
|
print_r($GLOBALS);
|
|
echo "</pre>";
|
|
?>
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
$db_connection = null;
|
|
?>
|