Example #1
0
function generate_todo_id()
{
    global $todosDB;
    //ensure db is initialized and available
    init_todos_db();
    $id = $todosDB["nextId"];
    todolog("json_data_access.php | pulled todo id: {$id}");
    return $id;
}
Example #2
0
         $_SESSION['taskId'] = $_POST['todoId'];
         //         var_dump($_SESSION);
         //         die();
         redirect(VIEWS . "/update_task.php");
     } else {
         $errors = array();
         array_push($errors, "Select a task!");
         $_SESSION["errors"] = $errors;
         redirect(VIEWS . "/home.php");
     }
     exit;
 } else {
     if ($action === "Delete") {
         todolog("todo.php | Trying to delete a todo");
         if (isset($_POST["todoId"])) {
             todolog("todo.php | todo id: " . $_POST["todoId"]);
             delete_todo($_POST["todoId"]);
         } else {
             $_SESSION["errors"] = array("Select a todo");
         }
         redirect(VIEWS . "/home.php");
         exit;
     } else {
         if ($action == "Update") {
             //$_SESSION["errors"] = array("Feature not implemented");
             //     var_dump($_POST);
             //     die();
             $todoId = $_POST["taskId"];
             $description = $_POST["description"];
             $status = $_POST["status"];
             $updated = update_todo($todoId, $description, $status);
Example #3
0
function delete_todo_object($id)
{
    todolog("mysql_data_access.php | trying to delete todo with id: {$id}");
    $stmt = "DELETE FROM todo WHERE id={$id}";
    $connection = get_connection();
    mysqli_query($connection, $stmt);
}
Example #4
0
                session_start();
            }
            session_regenerate_id(true);
            //valid user
            $_SESSION[CURRENT_USER] = $user[user_EMAIL];
            //redirect to home page
            redirect(VIEWS . "/home.php");
            exit;
        } else {
            todolog("auth.php | auth invalid");
            $errors = [];
            $errors["auth"] = "Authentication failed. Please check username and password";
            $_SESSION["errors"] = $errors;
            $url = APPLICATION_ROOT . "/index.php";
            redirect($url);
            exit;
        }
    } else {
        todolog("auth.php | user account not found");
        $errors = [];
        $errors["auth"] = "Authentication failed. Please check username and password";
        $_SESSION["errors"] = $errors;
        $url = APPLICATION_ROOT . "/index.php";
        redirect($url);
        exit;
    }
} else {
    todolog("auth.php | invalid request");
    redirect(APPLICATION_ROOT . "/index.php");
    exit;
}