Location: PHPKode > projects > WH Community > wh_community/admin/blog_posts_edit.php
<?php include('files/header.php'); ?>
<div id="content-outer">
<div id="content">

	<div id="page-heading">
		<h1><?php echo $lang_admin['blog_article_manage']; ?></h1>
	</div>
	
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized"><img src="files/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="files/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td><div id="content-table-inner">
			<div id="table-content">
			<p><?php
		
			if((isset($_GET['blog_id'])) && (is_numeric($_GET['blog_id'])) ) {
			$blog_id = $_GET['blog_id'];
			$blog_id = intval($_GET['blog_id']);
			
			}elseif((isset($_POST['blog_id'])) && (is_numeric($_POST['blog_id'])) ) {
			$blog_id = $_POST['blog_id'];
			$id = intval($_GET['id']);
			
				}else{
				
				echo '<p>' . $lang_admin['choose_it_a'] . '</p>';
				exit();
				}
			
			if(isset($_POST['submitted'])) {
			$errors = array();
			
			if(empty($_POST['title'])) {
			$errors[] = '<p>' . $lang_admin['no_title'] . '</p>';
			
				}else{
				$title = $_POST['title'];
				}
		
			if(empty($_POST['name'])) {
			$errors[] = '<p>' . $lang_admin['no_author'] . '</p>';
			
				}else{
				$name = $_POST['name'];
				}
			
			if(empty($_POST['message'])) {
			$errors[] = '<p>' . $lang_admin['no_article_w'] . '</p>';
			
				}else{
				$message = $_POST['message'];
				}
			
			if(empty($errors)) {
			$query = "UPDATE blog SET title='$title', author='$name', post='$message' WHERE blog_id = '" . $blog_id . "'";
			$result = mysql_query($query);
			
			if($result) {
			echo '<p>' . $lang_admin['article_edited'] . ' [ <a href="blog.php">' . $lang_admin['go_on'] . '</a> ]</p>';
			
				}else{
				echo '<p>' . $lang_admin['article_not_edited'] . ' [ <a href="blog.php">' . $lang_admin['back'] . '</a> ]</p>';
				}
			
			}else{
			
			echo '<p>' . $lang_admin['following_errors_occurred'] . ':</p>
				  <p>[ <a href="blog_posts_edit.php?blog_id=' . $blog_id . '">' . $lang_admin['back'] . '</a> ]</p><br>';
			echo '<ul>';
			
			foreach($errors as $msg) {
			echo '<li>' . $msg . '</li>';
			}
			}
			echo '</ul>';
			
			}else{
			
			$query = "SELECT title, author, post, blog_id FROM blog WHERE blog_id = '" . $blog_id . "'";
			$result = mysql_query($query);
			$num = mysql_num_rows($result);
			$row = mysql_fetch_array ($result, MYSQL_NUM);
			
			$title = $row['0'];
			$name = $row['1'];
			$message = $row['2'];
			
			if($num == 1) {
			echo '<form action="?blog_id=edit_news&num=' . $blog_id . '" method="post">
				  <p>&nbsp;</p>
				  <p><input type="text" name="title" class="fields" size="30" maxlength="60" value="' . $title . '"> <strong>' . $lang_admin['title'] . '</strong></p>
				  <br>
				  <p><input type="text" name="name" class="fields" size="30" maxlength="35" value="' . $name . '"> <strong>' . $lang_admin['author'] . '</strong></p>
				  <br>
				  <p><strong>' . $lang_admin['w_article'] . '</strong> <br><textarea rows="10" cols="80" class="fields" name="message">' . $message . '</textarea></p>
				  <br>
				  <p><input type="submit" name="submit" class="button" value="' . $lang_admin['to_edit'] . '"></p>
				  <input type="hidden" name="submitted" value="TRUE"></p>
				  <input type="hidden" name="blog_id" value="' . $blog_id . '">';
			
			}else{
			
			echo '<p>' . $lang_admin['article_not_edited'] . '. - [ <a href="blog_posts_edit.php?blog_id=' . $blog_id . '">' . $lang_admin['back'] . '</a> ]</p>';
			}
			}
		
			?></p>
			</div>
		</div></td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
			
	<div class="clear"></div>
		 
	</div>

	<div class="clear">&nbsp;</div>

</div>
<div class="clear">&nbsp;</div>
</div>
<?php include('files/footer.php'); ?>
Return current item: WH Community