Location: PHPKode > projects > WH Community > wh_community/reply.php
<?php require('layout/header.php'); ?>

    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['succes_reply']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_reply']; ?>"
    	});    
        }                                
    </script>

<div id="content_wrapper">
    <div class="content"><?php

		if((isset($_GET['id'])) && (is_numeric($_GET['id']))) {
		
		$idb = mysql_real_escape_string($_GET['id']);
		$idb = intval($_GET['id']);
	
			}else{
			
			echo '<p align="center" class="false">' . $lang['invalid_id'] . '!</p>';
			exit();
			}
		
		if($_SERVER['REQUEST_METHOD'] != 'POST') {
		
        echo '<br><p align="center" class="false">' . $lang['not_called_directly'] . '.</p><br>';
		
			}else{
			
			include_once('functions/secure.php');
			protect_vars();
			
			if(sha1($_POST["zip"]) != $_POST["zip2"]) {
			
			echo '<p class="false">' . $lang['invalid_spam'] . '!</p>
			      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
		
		}else{
		
		if(!$_SESSION['signed_in']) {
		
        echo '<br><p class="false">' . $lang['you_need_to'] . ' <a href="signin.php">' . $lang['signin_s'] . '</a>.</p><br>';
		
    		}else{
    		
    		$errors = array();
		
    		if(isset($_POST['reply'])) {
    		if(trim($_POST['reply']) == "") {
    		$errors[] = '<p>' . $lang['enter_a_text'] . '.</p>';
    		}
    		
    			}else{
    			$errors[] = '<p>' . $lang['enter_a_text'] . '.</p>';
    			}
		
		if(!empty($errors)) {
		
		echo '<p class="false"><u>' . $lang['not_filled_all'] . '</u></p>
		      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p><br>';
		echo '<ul>';
		
		foreach($errors as $key => $value) {
		echo '<li>' . $value . '</li>'; 
		}
		echo '</ul>';
		
			}else{
			
			$sql = "INSERT INTO 
						posts(post_content,
						post_date,
						post_topic,
						post_by) 
					VALUES ('" . mysql_real_escape_string($_POST['reply']) . "',
						NOW(),
						'" . mysql_real_escape_string((int)$_GET['id']) . "',
						'" . (int)$_SESSION['user_id'] . "')";
			
			$result = mysql_query($sql) OR die(mysql_error());
		
		if(!$result) {
		
		echo '<br><p class="false">' . $lang['couldnot_reply'] . '</p>';
		echo "<script type=\"text/javascript\">showErrorMessage();</script>";
		
			}else{
			
			$autoforward = 3;
			
            echo '<br><p class="right">' . $lang['succes_reply'] . '</strong></p>
			      <p><meta http-equiv="refresh" content="' . $autoforward . '; URL=topic.php?id=' . htmlentities((int)$_GET['id']) . '">
			      <small>(' . $lang['redirected_in'] . ' ' . $autoforward . ' ' . $lang['seconds'] . '...)</small></p><br>
			      <p>' . $lang['if_no_redirection'] . ' - [ <a href="topic.php?id=' . htmlentities((int)$_GET['id']) . '">' . $lang['goto_answer'] . '</a> ]</p>';
			echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
		
        }}}}}
		
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community