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

@@ -1,27 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<body>
<?php
$servername = "localhost";
$username = "web";
$password = "Password456";
$dbname = "computer";
<?php
$servername = "localhost";
$username = "web";
$password = "Password456";
$dbname = "computer";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn)
{
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
}
$sql = "INSERT INTO FriendList VALUES user1, argv[0], true";
$result = mysqli_query($conn, $sql);
$sql = "UPDATE FriendList SET confirm = true WHERE username = argv[0] and friend = user1";
$result = mysqli_query($conn, $sql);
?>
$sql = "INSERT INTO FriendList VALUES user1, argv[0], true";
$result = mysqli_query($conn, $sql);
$sql = "UPDATE FriendList SET confirm = true WHERE username = argv[0] and friend = user1";
$result = mysqli_query($conn, $sql);
?>
</body>
</body>
</html>
<?php
$db_connection = null;
?>

View File

@@ -54,11 +54,13 @@
$db_connection->query($sql_statement);
$sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', true)";
$db_connection->query($sql_statement);
echo "Friend request confirmed! You are both friends with each other now.";
}
else
{
$sql_statement = "INSERT INTO friendList VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST['friend']."', false)";
$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>
<!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" -->
<style>
body {
background-color: #3B5998;
}
</style>
<?php
echo "<br>";
try{
$query = "INSERT INTO messages (sender, recipient, message, date, haveread) VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST["name"]."', '".$_POST["message"]."', NOW(), 'N')";
$db_connection->query($query);
print("Message Has been sent");
}
catch(Exception $e){
<?php
echo "<br>";
try{
$query = "INSERT INTO messages (sender, recipient, message, date, haveread) VALUES ('".$_SESSION["loggedInUser"]."', '".$_POST["name"]."', '".$_POST["message"]."', NOW(), 'N')";
$db_connection->query($query);
print("Message Has been sent");
}
catch(Exception $e){
echo "Exception: ".$e->getMessage().PHP_EOL;
}
?>
</body>
}
?>
</body>
</html>
<?php
$db_connection = null;
?>

View File

@@ -4,21 +4,23 @@
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="styling.css">
</head>
<body>
<!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" -->
<head>
<link rel="stylesheet" type="text/css" href="styling.css">
</head>
<body>
<!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" -->
<?php
echo '<pre>';
$query = "Select * from contacts where fname = '".$_POST["fname"]."' and lname = '".$_POST["lname"]."'";
foreach($db_connection->query($query) as $row){
<?php
echo '<pre>';
$query = "Select * from contacts where fname = '".$_POST["fname"]."' and lname = '".$_POST["lname"]."'";
foreach($db_connection->query($query) as $row){
print "First Name:\t".$row['fname']."\nLast Name:\t".$row['lname']."\nUsername:\t".$row['username']."\n";
}
echo '</pre>';
?>
</body>
}
echo '</pre>';
?>
</body>
</html>
<?php
$db_connection = null;
?>

View File

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

View File

@@ -4,24 +4,23 @@
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="styling.css">
</head>
<body>
<!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" -->
<h2><font color="white">Send a message</h2>
<head>
<link rel="stylesheet" type="text/css" href="styling.css">
</head>
<body>
<!--#include virtual="header.html" -->
<!--#include virtual="topNavBar.html" -->
<h2><font color="white">Send a message</h2>
<form method="post" action="messageSender.php">
<form method="post" action="messageSender.php">
Who are you sending it to?: <br><input type="text" name="name">
<br><br>
Message: <br><textarea name="message" rows="5" cols="40"></textarea>
<br><br>
<input type="submit" class="button">
</form>
</body>
</form>
</body>
</html>
<?php
$db_connection = null;
?>

View File

@@ -4,7 +4,7 @@
<a href="/messagesSent.php">Sent Messages</a>
<a href="/search.php">Search</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>
<!--Maybe show the user's name here?-->
<a href="/logout.php" style="float:right">Logout</a>

View File

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