-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_recipe.php
More file actions
79 lines (50 loc) · 1.85 KB
/
edit_recipe.php
File metadata and controls
79 lines (50 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
include 'config.php';
require_once('includes/models/Recipe.php');
require_once('includes/dataaccess/RecipeDataAccess.php');
session_start();
if(!$_SESSION['user_role'] == 'user')
{
header('location:login.php');
}
$da = new RecipeDataAccess($conn);
//echo($_GET['recipe_id'] . '<br>');
/*
*/
$recipe = new Recipe();
if(isset($_GET['recipe_id'])){
$da = new RecipeDataAccess($conn);
$recipe = $da->get_recipe_by_id($_GET['recipe_id']);
}
?>
<form method="POST">
Recipe Name:<br>
<input type="text" name="recipe_name" value="<?php echo($recipe->recipe_name)?>"/><br>
Enter the Steps:<br>
<textarea row ="20" cols ="50" id = "txtarea_comments" name="steps"><?php echo($recipe->steps)?></textarea><br>
Enter the ingrentients list:<br>
<textarea row ="20" cols ="50" id = "txtarea_comments "name="ingredients"><?php echo($recipe->ingredients)?></textarea><br>
Is this Recipe active?:<br>
<input type="text" name="recipe_active" value="<?php echo($recipe->recipe_active)?>"/><br>
<input type="submit" name ="btnSubmit"value="submit">
</form>
<?php
//checks to see if the button is pressed then runs an update statement
If(isset($_POST['btnSubmit'])){
$recipe_id =htmlentities($_REQUEST['recipe_id']);
$recipe_name=htmlentities($_REQUEST['recipe_name']);
$steps=htmlentities($_REQUEST['steps']);
$ingredients=htmlentities($_REQUEST['ingredients']);
$recipe_active =htmlentities($_REQUEST['recipe_active']);
$id = mysqli_real_escape_string($conn, $recipe_id);
//FROM transactions WHERE id = " . mysqli_real_escape_string($this->link, $id);
$query="UPDATE recipes SET `recipe_name` = '$recipe_name',
`steps`='$steps',
`ingredients` = '$ingredients' ,
`recipe_active` = '$recipe_active'
WHERE `recipe_id` = '$id'" ;
echo($query);
mysqli_query($conn, $query);
header('Location: user.php');
}
?>