Location: PHPKode > projects > BSW_Bulletin > update.php
<?php
include("config.php");


//check for required info from the query string
if (!isset($_GET["topic_id"])) {
	header("Location: topiclist.php");
	exit;
}

//verify the topic exists
$verify_topic_sql = "SELECT topic_id,topic_title,topic_owner,topic_text FROM forum_topics WHERE topic_id = '".$_GET["topic_id"]."'";
$verify_topic_res =  mysql_query($verify_topic_sql) or die(mysql_error($mysql));

if (mysql_num_rows($verify_topic_res) < 1) {
	//this topic does not exist
	$display_block = "<p><em>You have selected an invalid topic.<br/>
	Please <a href=\"topiclist.php\">try again</a>.</em></p>";
} else {
	//get the topic title
	while ($topic_info = mysql_fetch_array($verify_topic_res)) {
		$topic_title = stripslashes($topic_info['topic_title']);
		$topic_id = stripslashes($topic_info['topic_id']);
		$topic_owner = stripslashes($topic_info['topic_owner']);
		$topic_text = nl2br(stripslashes($topic_info['topic_text']));
	}

	//gather the posts
	$get_posts_sql = "SELECT post_id, post_text, DATE_FORMAT(post_create_time, '%b %e %Y at %r') AS fmt_post_create_time, post_owner,post_title FROM forum_posts WHERE topic_id = '".$_GET["topic_id"]."'ORDER BY post_create_time ASC";
	$get_posts_res = mysql_query($get_posts_sql) or die(mysql_error($mysql));

	//create the display string
	$display_block = "
	<table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\">
	<tr>
	<th class=\"topic\"width=\"20%\">AUTHOR</th>
	<th class=\"topic\"width=\"80%\">POST</th>
	</tr>";

	while ($posts_info = mysql_fetch_array($get_posts_res)) {
		$post_id = $posts_info['post_id'];
		$post_text = nl2br(stripslashes($posts_info['post_text']));
		$post_create_time = $posts_info['fmt_post_create_time'];
		$post_owner = stripslashes($posts_info['post_owner']);

		//add to display
	 	$display_block .= "
		<tr>
		<td width=\"20%\" valign=\"top\"class=\"nform\">".$post_owner."<br/>[".$post_create_time."]</td>
		<td width=\"80%\" valign=\"top\" >".$post_text."<br/><br/>
		
</td>
		</tr>";
	}

	//free results
	mysql_free_result($get_posts_res);
	mysql_free_result($verify_topic_res);

	//close connection to MySQL
	mysql_close($mysql);

	//close up the table
	$display_block .= "</table>";
}
?>
<html>
<head>
<title>BSW Topics</title>
<style type="text/css">
.style1 {
	text-align: center;
}
</style>
<link rel="stylesheet" type="text/css" href="bswstyle.css">
<script language="JavaScript" type="text/javascript" src="wysiwyg.js"></script>
</head>
<body>
<table align="center" width="900"><?php include('header.php');?></table>
<table align="center" width="900"><td width="25%" valign="top"align="right" class="topic"><?php if (isset($_COOKIE["user"]))
  echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
  echo "Welcome guest!<br />";?></td><td width="5%" valign="top"align="left" class="topic"><?php if (isset($_COOKIE["user"])){

		
            echo"<a class=\"bar\"href=\"logout.php\">Logout</a>";}	
			
               else {   			
                      header("Location: topic.php");}?></td><td width="40%" valign="top"align="center" class="topic"><?php $ip = getenv("REMOTE_ADDR") ; 

Echo "Your IP is " . $ip;?></td><td width="30%" class="topic" align="center"><?php include('count.php');?></td></table>
<table align="center" width="900">
<td  style="width:900px">
<?php echo $display_block; ?><br/>

<p class="bar" style="width:160px"><a href="addtopic.php">Return to Main Page</a></p></td></table>

<table align="center" width="900">
</table>


<form method="post" action="do_update.php">

<table align="center">
<td style="width=900px:border:none" class="topic">
<h3>update a Topic</h3></td></table>


<table align="center">

<input  type="hidden" name="topic_owner" value="<?php echo($topic_owner);?>" size="40" maxlength="150">
<input type="hidden" name="topic_id" value="<?php echo($topic_id);?>" size="40" maxlength="150">
<input  type="hidden" name="post_id" value="<?php echo($post_id);?>" size="40" maxlength="150">
<input  type="hidden" name="post_owner" value="<?php echo($post_owner);?>" size="40" maxlength="150">

<tr>
<td style="width:80px;height:20px" valign="middle" align="right">Topic Title:</td>
<td style="width:182px;height:20px">
<input type="text" name="post_title" value="<?php echo ($topic_title);?>" style="width: 179px" ></td></table>
<table align="center" style="width: 756px"><tr>
<td>Message:</td></tr>
<td><textarea id="post_text" name="post_text" rows="8"  wrap="virtual" style="width: 780px">
<?php echo("$post_text");?></textarea>
<script  type="text/javascript"language="JavaScript">
  generate_wysiwyg('post_text');
</script></td> </table>
<table style="width:100px"align="center"><td class="bar">
<p><input class="bar"type="submit" name="submit" value="Submit Update"></p></td></table></form>

<table align="center"width="900"><?php include('footer.php');?></table>
</body>

</html>
Return current item: BSW_Bulletin