Specifications

do_html_header(“$title”);
display_new_post_form($parent, $area, $title, $message, $name);
if($error)
echo “Your message was not stored. Make sure you have filled in all
fields and try again.”;
do_html_footer();
?>
After some initial setting up, this script checks whether the parent is zero or otherwise. If it is
zero, this is a new topic, and little further work is needed.
If this is a reply ($parent is the postid of an existing article), then the script goes ahead and
sets up the title and the text of the original message, as follows:
// 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));
The functions it uses here are get_post_title(), get_post_message(), and add_quoting().
These functions are all from the discussion_fns.php library. They are shown in Listings 29.9,
29.10, and 29.11, respectively.
LISTING 29.9 get_post_title() Function from discussion_fns.phpRetrieves a Messages
Title from the Database
function get_post_title($postid)
{
// extract one post’s name from the database
if(!$postid) return “”;
$conn = db_connect();
Building Practical PHP and MySQL Projects
P
ART V
736
LISTING 29.8 Continued
35 7842 CH29 3/6/01 3:34 PM Page 736