PHP Code:
<?php
include_once("config.php");
if(isset($_POST['update'])) {
$RecipeID = mysqli_real_escape_string($mysqli, $_POST['RecipeID']);
$Title= mysqli_real_escape_string($mysqli,$_POST['Title']);
$Ingredients= mysqli_real_escape_string($mysqli,$_POST['Ingredients']);
$Method= mysqli_real_escape_string($mysqli,$_POST['Method']);
$Category= mysqli_real_escape_string($mysqli,$_POST['Category']);
mysqli_query($mysqli, "UPDATE DatabaseName SET Title='".$Title."',Ingredients='".$Ingredients."',Method='".$Method."',Category='".$Category."' WHERE RecipeID='".$RecipeID."'");
header("Location: blah/blah/blah/domain.com/crud/index.php");
}
?>
<h1 style="text-align: center;">Edit Recipe.</h1>
<?php
$result = mysqli_query($mysqli, "SELECT * FROM DatabaseName WHERE RecipeID='".mysqli_real_escape_string($mysqli, $_GET['RecipeID'])."'");
$row = mysqli_fetch_array($result);
?>
<form name="update_recipe" method="post" action="">
<table border="0">
<tr>
<td>Title</td>
<td><input type="text" name="Title" value="<?php echo htmlentities($row['Title']); ?>"></td>
</tr>
<tr>
<td>Ingredients</td>
<td><textarea name='Ingredients'><?php echo htmlentities($row['Ingredients']); ?></textarea></td>
</tr>
<tr>
<td>Method</td>
<td><textarea name='Method'><?php echo htmlentities($row['Method']); ?></textarea></td>
</tr>
<tr>
<td>Category</td>
<td><input type="text" name="Category" value="<?php echo htmlentities($row['Category']); ?>"></td>
</tr>
<tr>
<td><input type="hidden" name="RecipeID" value=<?php echo htmlentities($_GET['RecipeID']);?>></td>
<td><input type="submit" name="update" value="1"></td>
</tr>
</table>
</form>