hi there, i'm currently building a cms, and have a submit and view page, that i build with help from a tutorial. Now i want to expand it and make an edit page. I have SQL knowledge from school and i know a little php, but i can't get the whole thing working. I'll post my current code when i get home from school. Thanks.
<?php
include("dbconnect.php");
if(!empty($title)) {
$id = addslashes($id);
$title = addslashes($title);
$user = addslashes($user);
$message = addslashes($message);
$sql = "UPDATE mynews (id, title, user, message) VALUES ('NULL', '$title','$user','$message','$date') WHERE (id='$id')";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
echo "Database Updated.";
} else {
?>
<form name="news" method="post" action="<?php echo $PHP_SELF; ?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="117"><font size="1">ID: </font> </td>
<td width="577">
<font size="1">
<input type="text" name="id" value="mysql_result($sql,0,'$id')" size="5">
</font>
</td>
</tr>
<tr>
<td width="117"><font size="1">Title: </font> </td>
<td width="577">
<font size="1">
<input type="text" name="title" value="mysql_result($sql,0,'$title')" size="20">
</font>
</td>
</tr>
<tr>
<td width="117"><font size="1">Username:</font></td>
<td width="577">
<font size="1">
<input type="text" name="user" value="mysql_result($sql,0,'$user')" size="10">
</font>
</td>
</tr>
<tr>
<td width="117"><font size="1">Message:</font></td>
<td width="577">
<font size="1">
<textarea name="message" value="mysql_result($sql,0,'$message')" rows=10 cols=20></textarea>
</font>
</td>
</tr>
</table>
<p>
<font size="1">
<input type="submit" name="Submit" value="Submit"></font>
</p>
</form>
<hr>
Previous Posts<br>
<?php
include("news.php");
}
?>