rough code
This commit is contained in:
@@ -1,52 +1,41 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<style>
|
|
||||||
body
|
|
||||||
{
|
|
||||||
background-color: #3B5998;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<h2><font color="white">friendbook</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$servername = "localhost";
|
require 'common.php';
|
||||||
$username = "web";
|
require 'loginRequired.php';
|
||||||
$password = "Password456";
|
|
||||||
$dbname = "computer";
|
|
||||||
|
|
||||||
// Create connection
|
|
||||||
$conn = mysqli_connect($servername, $username, $password, $dbname);
|
|
||||||
// Check connection
|
|
||||||
if (!$conn)
|
|
||||||
{
|
|
||||||
die("Connection failed: " . mysqli_connect_error());
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "SELECT friend FROM friendList WHERE username = 'user1' and confirm = false";
|
|
||||||
$result = mysqli_query($conn, $sql);
|
|
||||||
|
|
||||||
|
|
||||||
if (mysqli_num_rows($result) > 0)
|
|
||||||
{
|
|
||||||
// output data of each row
|
|
||||||
while($row = mysqli_fetch_assoc($result))
|
|
||||||
{
|
|
||||||
echo "friends: " . $row["friend"]. ;
|
|
||||||
echo "<button type='button' onclick='window.location.href = 'acceptFriend.php $row['friend']''>Accept Friend Request</button>";
|
|
||||||
echo "<br>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "0 results";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<title>friendbook Pending Friend Requests</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="styling.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--#include virtual="header.html" -->
|
||||||
|
<!--#include virtual="topNavBar.html" -->
|
||||||
|
<?php
|
||||||
|
try{
|
||||||
|
echo '<pre>';
|
||||||
|
echo "Pending Friends:\n\n";
|
||||||
|
$sql_select = "SELECT friend";
|
||||||
|
$sql_from = "FROM friendList";
|
||||||
|
$sql_where = "WHERE username = ".$_SESSION["loggedInUser"]."";
|
||||||
|
$sql_statement = $sql_select." ".$sql_from." ".$sql_where."";
|
||||||
|
foreach($db_connection->query($sql_statement) as $row)
|
||||||
|
{
|
||||||
|
echo "".$row["friend"]."";
|
||||||
|
echo "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</pre>';
|
||||||
</body>
|
}catch(PDOException $e){
|
||||||
|
echo "PDOException: ".$e->getMessage().PHP_EOL;
|
||||||
|
}catch(Exception $e){
|
||||||
|
echo "Exception: ".$e->getMessage().PHP_EOL;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<?php
|
||||||
|
$db_connection = null;
|
||||||
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user