I am trying to write a basic admin side to my cms where one page will update a page and also create a new page but it isnt working. please help.
<?php
include("nav.php");
include("dbconnect.inc");
if ($_POST['update'])
{
$sql ="INSERT INTO pages VALUES('$_POST[title]','$_POST[content]');";
$result = mysql_query($sql,$conn);
?>
<html>
<body>
<center><span style='font-family: arial; color: red;'>You have successfully added the page<?php echo $_POST[title]; ?><br>
<a href='index.php'>add another page</a></center>
</body>
</html>
<?php
}
elseif($_POST['update'])
{
$sql = "UPDATE pages SET title='".$_POST['title']."' ,
content ='".$_POST[content]."'
WHERE title = '".$_POST['title_value']."'";
$result = mysql_query($sql,$conn);
?>
<html>
<body>
<center><span style='font-family: arial; color: red;'>You have successfully updated the page <?php echo $_POST['title']; ?> page<br>
<a href='index.php'>Add </a>or <a href="index.php">edit</a> another page</center>
</body>
</html>
<?php
}
else
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="700" border="1" bordercolor="#000000" style="border-collapse: collapse" align="center" >
<tr>
<td height="82" colspan="2" align="center"> header </td>
</tr>
<tr>
<td align="center" valign="middle">
<?php nav(); ?>
</td>
<td align="center">
<form name="" method="post" action="index.php" onsubmit="savedocument()" >
<p>
<?php
$sql = "SELECT * from pages where title = '$_GET[id]' ";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_assoc($result);
?>
<input type="hidden" name="title_value" value="<?php echo $_GET[id]; ?>">
<input type="text" name="title" value="<?php echo $_GET[id]; ?>"><br><br>
<textarea name="content" rows="10" cols="30"><?php echo $row[content]; ?></textarea>
<br>
<p>
<input type="submit" name="update" value="submit">
</form>
</td>
</tr>
</table>
</body>
</html>
<?php
}
?>