<?php include_once "../database.php"; $json = file_get_contents('php://input'); $request = json_decode($json, true); $userid = isset($request["userid"]) ? $request["userid"] : ""; $agencyid = isset($request["agencyid"]) ? $request["agencyid"] : ""; deleteFavorite($userid, $agencyid);
$request = $_POST['request']; // 2. Call corresponding function if ($request == "login") { login(); } if ($request == "logout") { logout(); } if ($request == "register") { register(); } if ($request == "add-favorite") { addFavorite(); } if ($request == "delete-favorite") { deleteFavorite(); } function login() { // Establish DB connection $con = new mysqli("localhost", "root", "cjftns119", "DevLog"); // Get more fields $user_email = $_POST['u_email']; $user_pw = $_POST['u_pw']; $encrypted_pw = md5($user_pw); // Check if user exists first: $query = "SELECT * FROM dl_users WHERE u_email='{$user_email}'"; $result = $con->query($query); if ($result->num_rows == 1) { $row = $result->fetch_assoc(); if ($row['u_pw'] == $encrypted_pw) {
$action = getpost('action'); $favorite_id = getpost('favorite_id'); if ($action == '') { home(); } elseif ($action == 'editFavorite') { editFavorite($favorite_id); } elseif ($action == 'addFavorite') { addFavorite(); } elseif ($action == 'saveFavorite') { saveFavorite($favorite_id); } elseif ($action == 'importPlaylist') { importFavorite($favorite_id, 'import'); } elseif ($action == 'addPlaylist') { importFavorite($favorite_id, 'add'); } elseif ($action == 'deleteFavorite') { deleteFavorite($favorite_id); } elseif ($action == 'deleteFavoriteItem') { deleteFavoriteItem($favorite_id); } else { message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]action'); } exit; // +------------------------------------------------------------------------+ // | Home | // +------------------------------------------------------------------------+ function home() { global $cfg, $db; authenticate('access_favorite'); // formattedNavigator $nav = array();