Location: PHPKode > projects > WH Community > wh_community/create_msg.php
<?php include('framework/mysql.php'); ?>
<?php include('framework/config.php'); ?>
<?php include('framework/language.php'); ?>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript" src="functions/javascript/messagebox.js"></script>
    
    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['success_message']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_message']; ?>"
    	});    
        }                                
    </script>

<?php
		
		if($_SERVER['REQUEST_METHOD'] != 'POST') {
		
		echo '<p class="false">' . $lang['not_called_directly'] . '.</p>';
		
    	}else{
		
		$id = (int)$_SESSION['user_id'];
		
		include_once('functions/messagebox.php');
		
		$msg = htmlentities($_POST['inputField']);
		$msg = mysql_real_escape_string($_POST['inputField']);
		
		$errors = array();
		
		if(isset($_POST['inputField'])) {
		if(trim($_POST['inputField']) == "") {
		$errors[] = '<p>' . $lang['enter_a_message'] . '.</p>';
		}
		
		if(strlen($_POST['inputField']) > 140) {
		$errors[] = '<p>' . $lang['not_longer_140'] . '.</p>';
		}
	
			}else{
			$errors[] = '<p>' . $lang['enter_a_message'] . '.</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>';
		echo '<ul>';
		
		foreach($errors as $key => $value) {
		echo '<li>' . $value . '</li>'; 
		}
		echo '</ul>';
		
    		}else{
    		
    		$sql = "INSERT INTO
    					messagebox(msg_id2, message, date)
    				VALUES ('" . $id . "',
    					'" . $msg . "',
    					NOW()
    					)";
    					
    		$result = mysql_query($sql) OR die(mysql_error());
		
		if(!$result) {
		
		echo "<script type=\"text/javascript\">showErrorMessage();</script>";
		
			}else{
			
			$autoforward = 3;
			
			echo '<meta http-equiv="refresh" content="' . $autoforward . '; URL=messagebox.php?user_id=' . $id . '">';
			echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
		
        }}}
		
		echo '</table>';
		
?>
Return current item: WH Community