Specifications
First, look at the URL:
http://webserver/chapter29/new_post.php?parent=5
The parameter passed in as parent will be the parent postid of the new posting. If you click
New Post instead of Reply, you will get parent=0 in the URL.
Second, you will see that for a reply, the text of the original message is inserted and marked
with a “>” character as is the case in most mail and news reading programs.
Third, you can see that the title of this message defaults to the title of the original message pre-
fixed with “Re:”.
Let’s look at the code that produces this output. It is shown in Listing 29.8.
LISTING 29.8 new_post.php—Allows a User to Type a New Post or Reply to an Existing Post
<?
include (‘include_fns.php’);
if(!$area)
$area = 1;
if(!$error)
{
if(!$parent)
{
$parent = 0;
if(!$title)
$title = “New Post”;
}
else
{
// get post name
$title = get_post_title($parent);
// append Re:
if(strstr($title, “Re: “) == false )
$title = “Re: “.$title;
//make sure title will still fit in db
$title = substr($title, 0, 20);
//prepend a quoting pattern to the post you are replying to
$message = add_quoting(get_post_message($parent));
}
}
Building Web Forums
C
HAPTER 29
29
BUILDING WEB
FORUMS
735
35 7842 CH29 3/6/01 3:34 PM Page 735