View Single Post
Old 05-30-2022, 12:59 AM  
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
PHP Code:
<?php
include_once("config.php");
if(isset(
$_POST['update'])) {
    
$RecipeID mysqli_real_escape_string($mysqli$_POST['RecipeID']);
    
$Titlemysqli_real_escape_string($mysqli,$_POST['Title']);
    
$Ingredientsmysqli_real_escape_string($mysqli,$_POST['Ingredients']);
    
$Methodmysqli_real_escape_string($mysqli,$_POST['Method']);
    
$Categorymysqli_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>
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote