<?php session_start(); require_once 'application.php'; $difficulte = isset($_REQUEST["filtre"]) ? $_REQUEST["filtreDifficulte"] : ''; $longueur = isset($_REQUEST["filtre"]) ? $_REQUEST["filtreLongueur"] : ''; $idQuartier = isset($_REQUEST["filtre"]) ? $_REQUEST["filtreQuartier"] : ''; if (isset($_REQUEST["addParcoursId"])) { favorite($_SESSION["user"]["idUtilisateur"], $_REQUEST["addParcoursId"]); } ?> <!DOCTYPE html> <html lang="fr"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href="./images/bootstrap.ico"> <link href="BootStrap/css/bootstrap.css" rel="stylesheet"> <link href="./css/style.css" rel="stylesheet"> <script src="http://maps.googleapis.com/maps/api/js?key= AIzaSyB45lygduZiEszTK6nCOiUMnNkH4tTz70c"> </script> <script src="./js/JavaScript.js"> </script> <title>JogginGeneva</title> </head> <body>
<li><a href = "possibleRecipes.php?recipe=quick">Quick Recipes</a></li> <li><a href = "possibleRecipes.php?recipe=search">Search Recipes</a></li> </ul> </li> <li class="border"><a href = "myRecipes.php">My Recipes</a></li> <li class="border"><a href = "home.php?logout=true">Log Out</a></li> </ul> </div> </nav> <header> <h1>Recipe</h1> </header> <div id="wrapper"> <?php include 'controller.php'; if (isset($_GET["recipeId"])) { echo '<h2 id="rhead">'; if (favorite($_GET['recipeId'], $_SESSION['username'])) { echo '<img src="images/heart2.png" alt="heart" id="heart" title="heart">'; } else { echo '<img src="images/heart1.png" alt="heart" id="heart" title="heart">'; } echo '</h2>'; } ?> </div> </body> </html>
$servername = "okenso.com"; $username = "******"; $password = "******"; $dbname = "dev"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $error = false; $error_message = ""; $data = json_decode(file_get_contents('php://input'), true); $user = $data["username"]; $pid = $data["pid"]; $channelname = $data["channelname"]; $channelowner = $data["channelowner"]; favorite($conn, $user, $pid, $channelname, $channelowner); $conn->close(); $response = array('error' => $error, 'error_message' => $error_message, 'channelname' => $channelname, 'channelowner' => $channelowner, 'pid' => $pid); echo json_encode($response); function favorite($conn, $user, $pid, $channelname, $channelowner) { global $error, $error_message; $stmt = $conn->prepare("INSERT INTO users_fav_posts (ufp_username, ufp_chname, ufp_chowner, ufp_number) VALUES (?, ?, ?, ?)"); $stmt->bind_param("sssi", $user, $channelname, $channelowner, $pid); if (!$stmt->execute()) { $error = true; $error_message = "Either the post has already been favorited, or the post no longer exists"; } $stmt->close(); } ?>
<?php include "class.title.php"; include "{$_SERVER['DOCUMENT_ROOT']}/phase5/db/tvguruDB.php"; try { $con = new PDO(DB_CONNECTION_STRING, DB_USER, DB_PWD); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo $e->getMessage(); } if (isset($_POST['favorite'])) { switch ($_POST['favorite']) { case 'Favorite': favorite(); break; case 'Unfavorite': unfavorite(); break; } } if (isset($_POST['comment'])) { postComment($_POST['comment']); } $title = new Title(); function favorite() { session_start(); global $con; try { $sql = "UPDATE `users` SET `favorites` = CONCAT(`favorites`, :title) WHERE `users`.`username` = :name"; $sql = $con->prepare($sql);