コード例 #1
0
ファイル: action.php プロジェクト: hahnl/Database_Queries
$mysqli = new mysqli("oniddb.cws.oregonstate.edu", "hahnl-db", "3C15z4js2nneWpks", "hahnl-db");
if (!$mysqli || $mysqli->connect_errno) {
    echo "Error connecting to MySQLi Session:(" . $mysqli->connect_errno . "): " . $mysqli->connect_error;
}
#main.php functions:
if (isset($_POST["add"])) {
    addToDatabase();
}
if (isset($_POST["favorite"])) {
    favoriteRecipe();
}
if (isset($_POST["unfav"])) {
    unfavoriteRecipe();
}
if (isset($_POST["remove"])) {
    removeRecipe();
}
#mealtypes.php functions:
if (isset($_POST["addMealType"])) {
    addMealType();
}
if (isset($_POST["editMealType"])) {
    editMealType();
}
if (isset($_POST["removeMealType"])) {
    removeMealType();
}
#pantry.php functions:
if (isset($_POST["addToPantry"])) {
    addToPantry();
}
コード例 #2
0
//get logged username
$user = $_SESSION["username"];
//connect to db
$conn = connectToDb($servername, $username, $password, $dbname);
//get recipe name
$recipeName = getRecipeNameFromDB($conn, $recipeId);
//get author name
$authorName = getAuthorName($conn, $recipeId);
//check if valid id or not original author
if ($recipeName == '' || $authorName != $user) {
    header('Location: fail.php');
}
//if submit
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    //delete everything
    removeRecipe($conn, $recipeId);
    header('Location: my-recipes.php');
}
?>

<!DOCTYPE html>
<html>
	
	<head>
		 <meta charset="UTF-8">
		<meta name="description" content="A virtual cookbook that allows user's to view, create and share recipes.">
		<meta name="keywords" content="recipe, cookbook, food, ingredients">
		<meta name="author" content="Cookbook Network Inc.">
		<link rel="stylesheet" type="text/css" href="page_style.css">
		<link href='http://fonts.googleapis.com/css?family=Tangerine:700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=IM+Fell+Double+Pica' rel='stylesheet' type='text/css'>
コード例 #3
0
ファイル: delete.php プロジェクト: eoyarzun/CookbookNetwork
<?php

session_start();
include 'db-credentials.php';
include 'create-recipe-form.php';
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
if (isset($_GET["recipe_id"])) {
    $recipe_id = $_GET["recipe_id"];
    removeRecipe($conn, $recipe_id);
    header('Location: my-recipes.php');
} else {
    $id = $_GET["cookbook_id"];
    removeFromDbType("Friends", "type_id", $id, $conn);
    removeFromDbType("Tag", "type_id", $id, $conn);
    removeFromDb("Recipe_list", "cookbook_id", $id, $conn);
    removeFromDb("cookbook_list", "cookbook_id", $id, $conn);
    removeFromDb("cookbook", "cookbook_id", $id, $conn);
    header('Location: my-cookbooks.php');
}