Minor fixes and closing DB connections as needed
This commit is contained in:
@@ -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)
|
||||
{
|
||||
die("Connection failed: " . mysqli_connect_error());
|
||||
}
|
||||
// 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;
|
||||
?>
|
||||
|
||||
@@ -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\']";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
@@ -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){
|
||||
echo "Exception: ".$e->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
<?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>
|
||||
</html>
|
||||
<?php
|
||||
$db_connection = null;
|
||||
?>
|
||||
|
||||
@@ -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){
|
||||
print "First Name:\t".$row['fname']."\nLast Name:\t".$row['lname']."\nUsername:\t".$row['username']."\n";
|
||||
}
|
||||
echo '</pre>';
|
||||
?>
|
||||
|
||||
</body>
|
||||
<?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>
|
||||
</html>
|
||||
<?php
|
||||
$db_connection = null;
|
||||
?>
|
||||
|
||||
@@ -31,4 +31,6 @@
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
$db_connection = null;
|
||||
?>
|
||||
|
||||
@@ -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">
|
||||
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 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>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
$db_connection = null;
|
||||
?>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -9,20 +9,22 @@
|
||||
<link rel="stylesheet" type="text/css" href="styling.css">
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="header.html" -->
|
||||
<!--#include virtual="topNavBar.html" -->
|
||||
<?php
|
||||
echo '<br><pre>';
|
||||
echo "Username\tFirst Name\tLast Name\n\n";
|
||||
$query = "SELECT * FROM contacts WHERE username REGEXP '.*".$_POST["username"].".*'";
|
||||
|
||||
foreach($db_connection->query($query) as $row){
|
||||
print $row['username']."\t\t";
|
||||
print $row['fname']."\t\t";
|
||||
print $row['lname']."\n";
|
||||
}
|
||||
echo '</pre>';
|
||||
?>
|
||||
<!--#include virtual="header.html" -->
|
||||
<!--#include virtual="topNavBar.html" -->
|
||||
<?php
|
||||
echo '<br><pre>';
|
||||
echo "Username\tFirst Name\tLast Name\n\n";
|
||||
$query = "SELECT * FROM contacts WHERE username REGEXP '.*".$_POST["username"].".*'";
|
||||
|
||||
foreach($db_connection->query($query) as $row){
|
||||
print $row['username']."\t\t";
|
||||
print $row['fname']."\t\t";
|
||||
print $row['lname']."\n";
|
||||
}
|
||||
echo '</pre>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
$db_connection = null;
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user