im modifying some code i found from a tutorial site which is a simple news system but it didnt have the adding news function but it said it would be similiar to the add comments fucntion anyways ive tried doing it like this
echo "<HR width=\"300\">";
echo "<FORM action=\"{$_SERVER['PHP_SELF']}" .
"?action=addnews&id=$id\" method=POST>\n";
echo "Name: <input type=\"text\" " .
"width=\"30\" name=\"name\"><BR>\n";
echo "<TEXTAREA cols=\"40\" rows=\"5\" " .
"name=\"title\"></TEXTAREA><BR>\n";
echo "<TEXTAREA cols=\"40\" rows=\"5\" " .
"name=\"newstext\"></TEXTAREA><BR>\n";
echo "<input type=\"submit\" name=\"submit\" " .
"value=\"Add Comment\"\n";
echo "</FORM>\n";
Thats the form for posting a news item. the only trouble is i dont know about this $id as its automatically incremated
the fucntion is like this
function addnews($id) {
global $db;
/* insert the news*/
$query = "INSERT INTO news" .
"VALUES('{$_POST['name']}'," . "'{$_POST['title']}'," .
"'{$_POST['newstext']}')";
mysql_query($query);
echo "News entered. Thanks!<BR>\n";
echo "<a href=\"{$_SERVER['PHP_SELF']}" .
"?action=show&id=$id\">Back</a>\n";
echo "$name"."$title"."$newstext";
}
the news mysql table is like this as you can see im missing the postdate from up above but how do i add this or will it add it automatically?
id int(10) UNSIGNED No auto_increment
postdate timestamp(14) Yes NULL
title varchar(50) No
newstext text No
any help much appreciated.