I am new at PHP and MySQL, but feel I have learnt heaps; mainly from cutting, pasting and modifying various tutorials. The following, similar, code I got to work elsewhere, but I can't seem to repeat its success.
The following if-statement never evalutes as true and thus my update doesn't take place
if(isset($POST['firstname']))
{
$id = $POST['id'];
$firstname = $POST['firstname'];
$surname = $POST['surname'];
$email = $POST['email'];
$public = $POST['public'];
$entry = $_POST['entry'];
if(!get_magic_quotes_gpc())
{
$firstname = addslashes($firstname);
$surname = addslashes($surname);
$entry = addslashes($entry);
}
// update the article in the database
$query = "UPDATE tblguestbook ".
"SET firstname = '$firstname', surname = '$surname', email = '$email', public = '$public', entry = '$entry' ".
"WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
// 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');
echo "<p align='center'>Article updated</p>";
// now we will display $title & content
// so strip out any slashes
$firstname = stripslashes($firstname);
$surname = stripslashes($surname);
$entry = stripslashes($entry);
}
'firstname' is set in the following code, which is part of the form which has method="post"
<input name="firstname" type="text" id="firstname" value="<?=$firstname;?>">
What am I doing wrong?