1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4. <head>
5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6. <title>Forum Posting</title>
7. </head>
8. <body>
9. <?php // Script 5.8 - handle_post.php #6
10. /* This script receives five values from posting.html:
11. first_name, last_name, email, posting, submit */
12.
13. // Address error management, if you want.
14.
15. // Get the values from the $_POST array.
16. // Strip away extra spaces using trim():
17. $first_name = trim($_POST['first_name']);
18. $last_name = trim($_POST['last_name']);
19. $posting = trim($_POST['posting']);
20.
21. // Create a full name variable:
22. $name = $first_name . ' ' . $last_name;
23.
24. // Get a word count:
25. $words = str_word_count($posting);
26.
27. // Take out the bad words:
28. $posting = str_ireplace('badword', 'XXXXX', $posting);
29.
30. // Print a message:
31. print "<div>Thank you, $name, for your posting:
32. <p>$posting</p>
33. <p>($words words)</p></div>";
34.
35. ?>
36. </body>
37. </html>