Sorry $_SESSION['rcpid'] was in there just my typo.
And i appologise for the bad language i have removed it.
I added those variables but still no luck.
Its no an error but the database just isnt updating once i fill out the form and clik submit my code says recipe updating but the database doesnt change. Here it is in full.
<?php
include ('opendb.php');
include ('protect.php');
$id = $_SESSION['rcpid'];
/*$query = "SELECT username FROM recipe WHERE id =".$id;
$result = mysql_query($query) or die ('Error selecting username: ' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$username = $row['username'];
if( $_SESSION['author'] !== $username){
?> <?php
}*/
$nameupdate = $_POST['title'];
$ingridupdate = $_POST['ingrid'];
$recipeupdate = $_POST['recipe'];
if(!isset($_GET['id']))
{
$query = "SELECT name, ingridients, recipe FROM recipe WHERE id=".$id;
$result = mysql_query($query) or die('Error : ' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$title = $row['name'];
$ingrid = $row['ingridients'];
$recipe = $row['recipe'];
//UP DATE QUERY
if(isset($_POST['submit'])) {
$query = "UPDATE recipe SET name = '$nameupdate', ingridients = '$ingridupdate', recipe = '$recipeupdate'WHERE username = ".$_GET['id'];
$update = mysql_query($query);
echo "<p align='center'>Recipe updated</p>";
}
}
// update the article in the database
/* then remove the cached file
$cacheDir = dirname(__FILE__) . '/cache/';
$cacheFile = $cacheDir . '_' . $_GET['id'] . ' .html';
@unlink($cacheFile);
// and remove the index.html too because the file list
// is changed
@unlink($cacheDir . 'index.html');*/
?>
<html>
<head>
<title>Edit Recipe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
</style>
</head>
<body>
<center>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Username:</td><td>
<input type="text" name="username" value="<?php echo $_SESSION['author'] ?>"maxlength="60" readonly>
</td></tr>
<tr><td>Recipe Name:</td><td>
<input type="text" name="title" value="<?php echo $title ?>"maxlength="30">
</td></tr>
<tr><td>Ingridients:</td><td>
<textarea name="ingrid"rows="15" cols="30" value="<? echo $ingrid ?>">
</textarea>
</td></tr>
<tr><td>Recipe:</td><td>
<textarea name="recipe" rows="30" cols="60" value="<? echo $recipe ?>">
</textarea>
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Update Recipe"></th></tr> </table>
</form>
</body>
</html>