Can someone help me fix the error of getting the Invalid Id thing when i go to post a new topic?
My Current Code:
My Current Code:
PHP:
<?
include "conn.php"; #include database file
if (is_numeric($_GET['id'])){ #check the valid id
if (isset($_GET['post'])){ #check to see if a post is made
$title=addslashes(htmlspecialchars($_POST['title'])); #post the title
$post=addslashes(htmlspecialchars($_POST['post'])); #post the post
$author=addslashes(htmlspecialchars($_POST['author'])); #post the author
mysql_query("INSERT INTO `post` ( `id` , `post` ) VALUES ('', '$post')")
or die(mysql_error());
#store the post in a seperate table
$pid=mysql_fetch_array(mysql_query("SELECT * FROM `post` ORDER BY `id` DESC LIMIT 1"))
or die(mysql_error());
#get the post you just stored
$pid=$pid['id']; #get the post you just stored
$time=time(); #set the time, this is for post bumping
$date=date("d/m/Y H:i:s");
$id=$_GET['id']; #get the valid id
$sql=mysql_query("INSERT INTO `thread`
( `id` , `title` , `postid` , `view` , `author` , `time` , `date` , `fid` )
VALUES ('', '$title', '$pid', '0', '$author', '$time', '$date', '$id')")
or die(mysql_error());
#store the thread information including the post id
if (!$sql){ #even with the or die() the sql may not work (believe it or not).
die ("An error occured Lol!");
exit; #exit if there is an error
}
echo "Success, your thread was added."; #yay, success ^_^
}
else {
?>
<form name="form1" method="post" action="?post=true&id=<? echo "$id"; ?>">
<table width="0%" border="1">
<tr>
<td>Title Of Thread </td>
<td><input type="text" name="title"></td>
</tr>
<tr>
<td>Main post of thread</td>
<td><textarea name="post" wrap="VIRTUAL"></textarea></td>
</tr>
<tr>
<td><br>
Author</td>
<td><input type="text" name="author"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
<?
}
}
else {
echo "Invalid Id";
# :o oh noes, error. This is if the id isnt numeric.
}
?>