Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto testing
  • Loading branch information
jsalzer312 committed May 28, 2024
2 parents 82c8d96 + 62541c8 commit ea1785e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 21 deletions.
39 changes: 39 additions & 0 deletions LAMPAPI/ChangeFavorite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$data = json_decode(file_get_contents('php://input'), true);

$conn = new mysqli("localhost", "TheBeast", "WeLoveCOP4331" ,"COP4331");

if ($conn->connect_error) {

return returnWithError($conn->connect_error);

} else {
$stmt = $conn->prepare("UPDATE Contacts SET Favorited=? WHERE ID=?;");
$stmt->bind_param("ss", $data["updatedFavorite"], $data["ID"]);
$stmt->execute();
$nrows = $stmt->affected_rows;

if ($nrows > 0) {
returnWithVerdict("");
} else {
returnWithVerdict("Something went wrong");
}
}


function sendResultInfoAsJson($obj) {
header("Content-type: application/json");
echo $obj;
}

function returnWithVerdict($verdict) {
$retValue = '{"verdict":"' . $verdict . '"}';
sendResultInfoAsJson($retValue);
}

?>
45 changes: 24 additions & 21 deletions contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link href="css/styles.css" rel="stylesheet" />
</head>
<body>
<header id="nav-header" class="text-black nav py-5 bg-accent">
<header id="nav-header" class="text-black nav py-5 bg-accent">
<div id="home-button" class= "header-link button" type="button">Home</div>
<a id="about-us_button" href="javascript:doLogout()"> <div id="about-us-button" class="header-link button" type="button">Logout</div></a>
<div id="about-link" class="header-link button" type="button">About</div>
Expand All @@ -34,6 +34,9 @@
<!--Search Bar-->
<div class="text-center my-6">
<div id="search-bar-row" class="search-bar row-alt">
<a id="search-favorites-off" href="favoriteSearch()" class="text-black a-link"><div id="searchAll" class="text-black refresh-page" type="button">0</div></a>
<a id="search-favorites-on" href="favoriteSearch()" class="text-black a-link" style="display:none"><div id="searchFaves" class="text-black refresh-page" type="button">1</div></a>
<input id="search-bar" type="text" placeholder="Search..." required onkeyup = "searchContact(null, null, null, null, null)">
<a id="refresh-button" href="javascript:firstPage(null, null)" class="text-black a-link"><div id="refreshButton" class="text-black refresh-page" type="button">Refresh</div></a>
<a id="add-contact-button" href="javascript:showTable()" class="text-black a-link"><div id="addContactButton" class="text-black refresh-page" type="button">Add Contact</div></a>
Expand All @@ -52,8 +55,8 @@
<div id="contact-delete" class="text-black icon-cell">Delete</div>
</div>
<div id="contact-row-1" class="cell">
<a id="contact-not-fave-1" href="javascript:favoriteContact(1)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-1" href="javascript:favoriteContact(1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-1" href="javascript:favoriteContact(1, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-1" href="javascript:favoriteContact(1, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-1" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -83,8 +86,8 @@
</div>
<div id="contact-row-2" class="cell">
<a id="contact-not-fave-2" href="javascript:favoriteContact(2)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-2" href="javascript:favoriteContact(2)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-2" href="javascript:favoriteContact(2, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-2" href="javascript:favoriteContact(2, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-2" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -114,8 +117,8 @@
</div>
<div id="contact-row-3" class="cell">
<a id="contact-not-fave-3" href="javascript:favoriteContact(3)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-3" href="javascript:favoriteContact(3)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-3" href="javascript:favoriteContact(3, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-3" href="javascript:favoriteContact(3, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-3" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -145,8 +148,8 @@
</div>
<div id="contact-row-4" class="cell">
<a id="contact-not-fave-4" href="javascript:favoriteContact(4)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-4" href="javascript:favoriteContact(4)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-4" href="javascript:favoriteContact(4, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-4" href="javascript:favoriteContact(4, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-4" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -176,8 +179,8 @@
</div>
<div id="contact-row-5" class="cell">
<a id="contact-not-fave-5" href="javascript:favoriteContact(5)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-5" href="javascript:favoriteContact(5)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-5" href="javascript:favoriteContact(5, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-5" href="javascript:favoriteContact(5, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-5" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -207,8 +210,8 @@
</div>
<div id="contact-row-6" class="cell">
<a id="contact-not-fave-6" href="javascript:favoriteContact(6)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-6" href="javascript:favoriteContact(6)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-6" href="javascript:favoriteContact(6, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-6" href="javascript:favoriteContact(6, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-6" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -238,8 +241,8 @@
</div>
<div id="contact-row-7" class="cell">
<a id="contact-not-fave-7" href="javascript:favoriteContact(7)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-7" href="javascript:favoriteContact(7)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-7" href="javascript:favoriteContact(7, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-7" href="javascript:favoriteContact(7, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-7" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -269,8 +272,8 @@
</div>
<div id="contact-row-8" class="cell">
<a id="contact-not-fave-8" href="javascript:favoriteContact(8)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-8" href="javascript:favoriteContact(8)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-8" href="javascript:favoriteContact(8, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-8" href="javascript:favoriteContact(8, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-8" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -299,8 +302,8 @@
<a id="contact-cancel-edit-8" href="javascript:cancelContact(8)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" class="text-black icon-cell" type="button">Cancel</div></a>
</div>
<div id="contact-row-9" class="cell">
<a id="contact-not-fave-9" href="javascript:favoriteContact(9)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-9" href="javascript:favoriteContact(9)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-9" href="javascript:favoriteContact(9, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-9" href="javascript:favoriteContact(9, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-9" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down Expand Up @@ -330,8 +333,8 @@
</div>
<div id="contact-row-10" class="cell">
<a id="contact-not-fave-10" href="javascript:favoriteContact(10)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-10" href="javascript:favoriteContact(10)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<a id="contact-not-fave-10" href="javascript:favoriteContact(10, 0)" class="icon-cell text-black a-link-alt"><div id="editButton" class="text-black icon-cell" type="button">0</div></a>
<a id="contact-fave-10" href="javascript:favoriteContact(10, 1)" class="icon-cell text-black a-link-alt" style="display:none"><div id="editButton" type="button">1</div></a>
<span id="contact-first-name-10" class="cell text-black"></span>
<div class="search-bar cell text-black">
Expand Down

0 comments on commit ea1785e

Please sign in to comment.