12-23-2007, 01:35 PM
|
#18 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
You already see all the code? :S
newpost.php
php Code:
<?php/** * @author Tanax * @copyright 2007 */ include('includes/config.php'); $t = $_GET[ 't']; if(! $_POST[ 'submit'] ) { ?> <form action= "newpost.php" method= "POST"> Author:<br /> <input type= "text" name= "author" /><br /> Post:<br /> <input type= "text" name= "post" /><br /> <input type= "submit" value= "Post" name= "submit" /> </form> <?php } else { $newpost = array(); $newpost[ 'author'] = $_POST[ 'author']; $newpost[ 'content'] = $_POST[ 'post']; if($tanaxia[ 'forum']-> newPost($newpost, $t)) { echo 'Reply posted!'; } else { echo 'Couldn\'t post reply..'; } }?>
forum.php (the class)
php Code:
public function newPost ($details, $thread) { $sql = sprintf(" INSERT INTO `%s` SET `%s` = NOW(), `%s` = '%s', `%s` = '%s', `%s` = '%s'", $this-> db-> table[ 'posts'], $this-> db-> col[ 'post_time'], $this-> db-> col[ 'post_content'], $details[ 'content'], $this-> db-> col[ 'post_author'], $details[ 'author'], $this-> db-> col[ 'post_thread'], $thread); $query = $this-> db-> query($sql); if($query) { return true; } return false; }
showthread.php
php Code:
<?php/** * @author Tanax * @copyright 2007 */ include('includes/config.php'); $t = $_GET[ 't']; if(! isset($t)) { echo 'Please specify a valid thread'; } else { $thread = $tanaxia[ 'forum']-> getThreadInfo($t); $forum = $tanaxia[ 'forum']-> getForumInfo($thread[ 'thread_forum'] ); $category = $tanaxia[ 'forum']-> getForumInfo($forum[ 'forum_parent'] ); $posts = $tanaxia[ 'forum']-> getPosts($thread[ 'thread_id'] ); echo '<a href="index.php">Index</a> -> <a href="forumdisplay.php?f='. $category[ 'forum_id']. '">'. $category[ 'forum_name']. '</a> '; echo '-> <a href="forumdisplay.php?f='. $forum[ 'forum_id']. '">'. $forum[ 'forum_name']. '</a> '; echo '-> <a href="showthread.php?t='. $thread[ 'thread_id']. '">'. $thread[ 'thread_name']. '</a>'; echo '<center>'; foreach($posts as $post) { echo '<table width="900" border="1">'; echo '<tr>'; echo '<td colspan="3"><font size="2">Posted '. $post[ 'post_time']. '</font></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2" width="30%">'. $post[ 'post_author']. '</td>'; echo '<td>'. $post[ 'post_content']. '</td>'; echo '</tr></table><br />'; } echo '<a href="newpost.php?t='. $t. '">Post reply</a>'; echo '</center>'; }?>
|
|
|
|