Minor fixes and closing DB connections as needed

This commit is contained in:
WilliamMiceli
2019-12-04 21:48:04 -05:00
parent 5bb11b100b
commit d5f3df965f
9 changed files with 95 additions and 95 deletions

View File

@@ -24,4 +24,6 @@ $result = mysqli_query($conn, $sql);
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>

View File

@@ -54,11 +54,13 @@
$db_connection->query($sql_statement); $db_connection->query($sql_statement);
$sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', true)"; $sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', true)";
$db_connection->query($sql_statement); $db_connection->query($sql_statement);
echo "Friend request confirmed! You are both friends with each other now.";
} }
else else
{ {
$sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', false)"; $sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', false)";
$db_connection->query($sql_statement); $db_connection->query($sql_statement);
echo "Friend request sent to $_POST[\'friend\']";
} }
} }
} }

View File

@@ -1,3 +0,0 @@
<?php
phpinfo();
?>

View File

@@ -13,25 +13,19 @@
<body> <body>
<!--#include virtual="header.html" --> <!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" --> <!--#include virtual="topNavBar.html" -->
<style>
body {
background-color: #3B5998;
}
</style>
<?php <?php
echo "<br>"; echo "<br>";
try{ try{
$query = "INSERT INTO messages (sender, recipient, message, date, haveread) VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST["name"]."', '".$_POST["message"]."', NOW(), 'N')"; $query = "INSERT INTO messages (sender, recipient, message, date, haveread) VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST["name"]."', '".$_POST["message"]."', NOW(), 'N')";
$db_connection->query($query); $db_connection->query($query);
print("Message Has been sent"); print("Message Has been sent");
} }
catch(Exception $e){ catch(Exception $e){
echo "Exception: ".$e->getMessage().PHP_EOL; echo "Exception: ".$e->getMessage().PHP_EOL;
} }
?> ?>
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>

View File

@@ -19,6 +19,8 @@ foreach($db_connection->query($query) as $row){
} }
echo '</pre>'; echo '</pre>';
?> ?>
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>

View File

@@ -31,4 +31,6 @@
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>

View File

@@ -19,9 +19,8 @@
<br><br> <br><br>
<input type="submit" class="button"> <input type="submit" class="button">
</form> </form>
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>

View File

@@ -4,7 +4,7 @@
<a href="/messagesSent.php">Sent Messages</a> <a href="/messagesSent.php">Sent Messages</a>
<a href="/search.php">Search</a> <a href="/search.php">Search</a>
<a href="/sendMessage.php">Message Someone</a> <a href="/sendMessage.php">Message Someone</a>
<a href="/findFriend.php">Find a New Friend</a> <a href="/findFriend.php">Add a Friend</a>
<a href="/pendingFriend.php">Check Pending Friends</a> <a href="/pendingFriend.php">Check Pending Friends</a>
<!--Maybe show the user's name here?--> <!--Maybe show the user's name here?-->
<a href="/logout.php" style="float:right">Logout</a> <a href="/logout.php" style="float:right">Logout</a>

View File

@@ -23,6 +23,8 @@
} }
echo '</pre>'; echo '</pre>';
?> ?>
</body> </body>
</html> </html>
<?php
$db_connection = null;
?>