Jump to content

Recommended Posts

http://puu.sh/4v6WV.png
http://puu.sh/4v6Wq.png
 

 

Provided some pictures below,



<?php

	// Page Initialization
	$level = '';
	$page = 'post';
	include($level.'includes/config.php');
	
	// Variables
	$error = $success = "";
	
	// Get Post Info
	if (isset($_GET['id'])) {
		$post = $POSTS->getPostById($_GET['id']);
		if (!$post) {
			if (isset($_SESSION['last_page'])) {
				header('Location: '.$_SESSION['last_page']);
			} else {
				header('Location: index.php');
			}
		}
	} else {
		if (isset($_SESSION['last_page'])) {
			header('Location: '.$_SESSION['last_page']);
		} else {
			header('Location: index.php');
		}
	}
	
	// POST - Reply
	if (isset($_POST['reply'])) {
		$reply = strip_tags(Clean($_POST['reply']));
		if ($reply != "") {
			$time = time();
			$DB->RowInsert('replies', array('post' => $post->id, 'posted' => $time, 'user' => $_SESSION['user_id'], 'content' => $reply));
			$DB->FieldSet('posts', 'lastupdated', $time, 'id', $post->id);
		} else {
			$error = "Enter a Reply";
		}
	}
	
	// Set Last Page
	$_SESSION['last_page'] = 'post.php?id='.$_GET['id'];
?>

<?php include("parts/doctype.php"); ?>

<head>
	<title><?php echo $post->title; ?></title>
	<?php include("parts/meta.php"); ?>
</head>

<body>

<div id="whole">

	<div id="header"><?php include("parts/header.php"); ?></div>
	
	<div id="main">
	
		<h1><?php echo stripslashes($post->title); ?></h1>
	
		<div class="postrow">
		<a href="user.php?id=<?php echo $post->user; ?>"><img class="usericon" src="images/users/<?php echo $DB->FieldGet('users', 'avatar', 'id', $post->user); ?>" alt="<?php echo $DB->FieldGet('users', 'firstname', 'id', $post->user); ?>" title="<?php echo $DB->FieldGet('users', 'firstname', 'id', $post->user); ?>"></a>
			<div class="posttext">
			<p><?php echo stripslashes(nl2br($post->content)); ?></p>
			<?php if ($DB->FieldGet('users', 'permissions', 'id', $_SESSION['user_id']) == 1) { ?>
			<a href='delete_post.php?id=<?php echo $post->id; ?>'><img class="deleteicon2" src="images/delete.png" alt="Delete Reply" title="Delete Reply"></a>
			<?php } ?>
			<p class="timestamp"><?php echo date('F j, Y', $post->posted); ?> at <?php echo date('g:i a', $post->posted); ?></p>
			</div>
		</div>
		
		<?php 
			$replies = $POSTS->getReplies($post->id);
			if ($replies) {
				foreach ($replies as $reply) {?>
					<div class="postrow">
					<a href="user.php?id=<?php echo $reply->user; ?>"><img class="usericon" src="images/users/<?php echo $DB->FieldGet('users', 'avatar', 'id', $reply->user); ?>" alt="<?php echo $DB->FieldGet('users', 'firstname', 'id', $reply->user); ?>" title="<?php echo $DB->FieldGet('users', 'firstname', 'id', $reply->user); ?>"></a>
						<div class="posttext">
						<p><?php echo stripslashes(nl2br($reply->content)); ?></p>
						<?php if ($DB->FieldGet('users', 'permissions', 'id', $_SESSION['user_id']) == 1) { ?>
						<a href='delete_reply.php?id=<?php echo $reply->id; ?>'><img class="deleteicon2" src="images/delete.png" alt="Delete Reply" title="Delete Reply"></a>
						<?php } ?>
						<p class="timestamp"><?php echo date('F j, Y', $reply->posted); ?> at <?php echo date('g:i a', $reply->posted); ?></p>
						</div>
					</div>
				<?php }
			}
		?>
	
		<?php if ($USERS->checkLogin()) { ?>
				
		<div id="replybox">
		<img class="usericon" src="images/users/<?php echo $DB->FieldGet('users', 'avatar', 'id', $_SESSION['user_id']); ?>" alt="<?php echo $DB->FieldGet('users', 'firstname', 'id', $_SESSION['user_id']); ?>" title="<?php echo $DB->FieldGet('users', 'firstname', 'id', $_SESSION['user_id']); ?>">
		<form method='POST'>
		<?php if ($error != "") { print("<p class='error4'>".$error."</p>"); } ?>	
		<textarea id="reply" name='reply'></textarea>
		<input type="submit" class="button" value="Reply">
		</form>
		</div>
		
		<?php } ?>
	
	</div>
	
	<div class="clear"></div>
	
	<div id="footerhome"><?php include("parts/footer.php"); ?></div>

</div>
	
</body>
</html>

And the post.php

Link to comment
https://forums.phpfreaks.com/topic/282286-forum-system-wont-make-new-lines/
Share on other sites

Ah, sorry. Then I saw you already use nl2br.

Try to replace:

<p><?php echo stripslashes(nl2br($reply->content)); ?></p>

with:

<p><?php echo nl2br(stripslashes($reply->content)); ?></p>
Edited by cataiin

You don't see anything when adding the following line of code?  :confused:

<?php
echo $reply->content;
?>

If it outputs something, what is the exact text?

 

 

Also, I just noticed that there are two similar variables. Which one should we be focusing on?

<p><?php echo stripslashes(nl2br($post->content)); ?></p>
<p><?php echo stripslashes(nl2br($reply->content)); ?></p>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.