} if (isset($_GET['addHere'])) { header('Location: addLink.html?userID=' . $_SESSION['id']); } if (isset($_GET['addTHere'])) { header('Location: addTeam.html?userID=' . $_SESSION['id']); } if (isset($_GET['addPHere'])) { header('Location: addProject.html?userID=' . $_SESSION['id']); } if (isset($_GET['add'])) { //echo "UserID: ".$_GET['userID']; //First search to check it's a new link $command = "SELECT * FROM Social_Network WHERE Link = :link"; $params = array(":link" => $_GET['newSLink']); $results = $dbConn->executeWithReturn($command, $params); if (count($results) != 0) { $msg = "This link is already taken."; header('Location: errorManipulate.php?userID=' . $_SESSION['id'] . '&msg=' . $msg); } $command = "INSERT INTO Social_Network (Name, Link, UserID) VALUES (:sname, :link, :userID)"; $params = array(":sname" => $_GET['newSName'], ":link" => $_GET['newSLink'], ":userID" => $_SESSION['id']); $dbConn->executeWithoutReturn($command, $params); header('Location: edit.php?userID=' . $_SESSION['id']); } if (isset($_GET['addTeam'])) { //First search to check it's a new team $command = "SELECT * FROM Membership WHERE Team_Name = :tname AND Username = :uname"; $params = array(":tname" => $_GET['newTName'], ":uname" => $_SESSION['id']); $results = $dbConn->executeWithReturn($command, $params); if (count($results) != 0) {
namespace directory; require 'DBHandler.php'; require 'vendor/autoload.php'; //if (session_status() === PHP_SESSION_ACTIVE) ? TRUE : FALSE; session_start(); $_SESSION['id'] = $_GET['userID']; $servername = 'localhost'; $dbname = 'directory'; $dBUsername = '******'; $dBPassword = ''; $dbConn = new DBHandler("mysql:host={$servername};dbname={$dbname}", $dBUsername, $dBPassword); $dbConn->connect(); $command = "SELECT * from Employee where User_Name LIKE :username"; $params = array(":username" => $_GET['userID']); $result = $dbConn->executeWithReturn($command, $params); foreach ($result as $res) { } $command = "SELECT Name, Family_Name, User_Name, Photo from Employee"; $params = array(); $result2 = $dbConn->executeWithReturn($command, $params); foreach ($result2 as $res2) { } $command = "SELECT * from Social_Network where UserID LIKE :userID"; $params = array(":userID" => $_GET['userID']); $result3 = $dbConn->executeWithReturn($command, $params); foreach ($result3 as $res3) { } $command = "SELECT * from Membership where Username LIKE :userID"; $params = array(":userID" => $_GET['userID']); $teams = $dbConn->executeWithReturn($command, $params);
namespace directory; require 'DBHandler.php'; session_start(); $servername = 'localhost'; $dbname = 'directory'; $dBUsername = '******'; $dBPassword = ''; $dbConn = new DBHandler("mysql:host={$servername};dbname={$dbname}", $dBUsername, $dBPassword); $dbConn->connect(); //Check if select any new team if (isset($_GET['valueT']) && !empty($_GET['valueT'])) { $selectedTeam = $_GET['valueT']; $command = "INSERT INTO Membership (Username, Team_Name) VALUES (:userID, :tname)"; $params = array(":tname" => $selectedTeam, ":userID" => $_SESSION['id']); $dbConn->executeWithoutReturn($command, $params); } //Check if select any new project if (isset($_GET['valueP']) && !empty($_GET['valueP'])) { $selectedProject = $_GET['valueP']; $command = "INSERT INTO Develop (Username, Project_Name) VALUES (:userID, :pname)"; $params = array(":pname" => $selectedProject, ":userID" => $_SESSION['id']); $dbConn->executeWithoutReturn($command, $params); } $command = "SELECT Team_Name from Membership where Username != :userID"; $params = array(":userID" => $_SESSION['id']); $otherTeams = $dbConn->executeWithReturn($command, $params); $otherTeams = array_unique($otherTeams, SORT_REGULAR); foreach ($otherTeams as $otherTeam) { print_r($otherTeam); }