Renamed; added $_POST to be shown

This commit is contained in:
WilliamMiceli
2019-11-25 14:11:39 -05:00
parent c4d2fcf1b5
commit eba4ae6401

70
var/www/debug.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
session_start();
$server = "localhost";
$database = "friendBook";
$username = "web";
$password = "Password456";
?>
<html>
<head>
</head>
<body>
<h1>PHP Test Page</h1>
<h2>MySQL</h2>
<h3>Creating Connection</h3>
<?php
try{
$connection = new PDO("mysql:host=$server;dbname=$database", $username, $password);
// set the PDO error mode to exception
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully".PHP_EOL;
}
catch(PDOException $e){
echo "Connection failed: ".$e->getMessage().PHP_EOL;
}
?>
<h3>Creating and Executing Query</h3>
<?php
try{
$sql = "SELECT messageID, date, message FROM messages WHERE recipient={$_SESSION["loggedInUser"]}";
foreach($connection->query($sql) as $row){
print $row['messageID']."\t";
print $row['date']."\t";
print $row['message']."\t";
}
}
catch(Exception $e){
echo "Error: ".$e->getMessage().PHP_EOL;
}
?>
<h3>$sql</h3>
<?php
echo "<pre>";
print_r($sql);
echo "</pre>";
?>
<h3>$_POST</h3>
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>
<h3>$_SESSION</h3>
<?php
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
?>
</body>
</html>
<?php
$connection = null;
?>