Hi there,
I'm very new to this and have what appears to be a simple problem updating files on the cms I have created.
What happens is that when I submit the form, it simply reloads the page without the added updates.
if anyone can help that would be great. here is my code...
<html>
<head>
<title>Edit An Article</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css"></style>
</head>
<body>
<br>
<?php
include 'library/config.php';
include 'library/opendb.php';
if(isset($GET['id']))
{
$query = "SELECT id, title, content ".
"FROM company_overview ".
"WHERE id = '{$GET['id']}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);
$content = htmlspecialchars($content);
}
else if(isset($POST['save']))
{
$id = $POST['id'];
$title = $POST['title'];
$content = $POST['content'];
if(!get_magic_quotes_gpc())
{
$title = addslashes($title);
$content = addslashes($content);
}
// update the article in the database
$query = "UPDATE company_overview
SET title = '$title', content = '$content' ".
"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 "Article '$title' updated";
// now we will display $title & $content
// so strip out any slashes
$title = stripslashes($title);
$content = stripslashes($content);
}
include 'library/closedb.php';
?>
<table width="525" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#999999">
<tr>
<td bgcolor="#FFFFFF">
<form method="post">
<input type="hidden" name="id" value="<?=$id;?>">
<table width="525" border="0" cellpadding="2" cellspacing="1" class="box">
<tr>
<td width="100"><h3><b>Title</b></h3></td>
<td><input name="title" type="text" class="box" id="title" value="<?=$title;?>"></td>
</tr>
<tr>
<td width="100"><h3><b>Content</b></h3></td>
<td><textarea name="content" cols="50" rows="15" class="box" id="content"><?=$content;?></textarea></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Update Article"></td>
</tr>
</table>
</form>
<p align="center"><FORM><INPUT TYPE="button" VALUE="<--- Back" onClick="history.go(-1);return true;"> </FORM></p>
</td>
</tr>
</table>
</body>
</html>