Adding Posts to a Topic
In this final step, you will create replytopost.php, which will look remarkably similar to the form and script used to add a topic. Listing 19.5 shows the code for this all-in-one form and script.
Listing 19.5. Script to Add Replies to a Topic
1: <?php 2: //connect to server and select database; we'll need it soon 3: $conn = mysql_connect("localhost", "joeuser", "somepass") 4: or die(mysql_error()); 5: mysql_select_db("testDB",$conn) or die(mysql_error()); 6: 7: //check to see if we're showing the form or adding the post 8: if ($_POST[op] != "addpost") { 9: // showing the form; check for required item in query string 10: if (!$_GET[post_id]) { 11: header("Location: topiclist.php"); 12: exit; 13: } 14: 15: //still have ... |
Get Sams Teach Yourself PHP, MySQL® and Apache All in One now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.