File edit.php in CookBook

<?php require_once('Include/config.php'); ?>
<?php if( !$userdata['session_logged_in'] ) {?>
You must <a href="http://www.fuzzymonk.com/forum/login.php?redirect=../chris/cookbook/">Login</a> in order to view this page.
<? exit(); }?>
<html>
<head>
<title>Edit Recipe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="cookbook.css" rel="stylesheet" type="text/css">
</head>
 
<body>
 
<div id="main">
<?php
if ($submit) {
 
  // process form
 
  $sql = "UPDATE cookbook_recipes SET title = '$title', ingredients = '$ingredients', directions = '$directions' WHERE id = '$id'";
	//echo $sql;
  $result = mysql_query($sql);
 
	//print ($_POST['id']);
 
   echo "Recipe Saved.\n [<a href=\"view.php?id=". $_POST['id'] . "\">Back to recipe</a>][<a href=\"index.php\">Back to index</a>][<a href=\"add.php\">Add New Recipe</a>]";
 
 
 
} else
{
 
	if(isset($_GET['id']))
		{$id = $_GET['id'];}
	else
		{print("Error: Invalid ID.  Looser.");exit;}
		
  $sql = "SELECT * FROM cookbook_recipes WHERE id=" . $id;
  $result = mysql_query($sql);
 
  // display form
  ?>
  <form method="post" action="<?php echo $PHP_SELF?>">
  Title:<br>
  <input name="title" type="Text" size="75" maxlength="255" value="<?php print(mysql_result($result,0,"title")); ?>"><br>
  Ingredients:<br>
  <textarea name="ingredients" cols="75" rows="6"><?php print(mysql_result($result,0,"ingredients")); ?></textarea><br>
  Directions:<br>
   <textarea name="directions" cols="75" rows="6"><?php print(mysql_result($result,0,"directions")); ?></textarea><br>
   <input name="id" type="hidden" value="<?php echo $id; ?>">
 
  <input type="Submit" name="submit" value="Save Changes">
 
  </form>
 
  <?php
} // end if
?>
 
 
<div class="copyright" align="center">&copy; 2004 <a href="http://www.fuzzymonk.com">Chrisopher Sexton</a></div>
</div></body>
</html>
 
 
 
  code/cookbookedit.txt · Last modified: 2005/01/06 11:42
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki