Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I am getting this error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\Forum\replytopost.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\Forum\replytopost.php on line 40
While using this code:Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
$conn = mysql_connect("localhost");
mysql_select_db("forum",$conn);
if ($_POST[op] != "addpost") {
if (!$_GET[post_id]) {
header("Location: topic_list.php");
exit;
};
$verify = "select ft.topic_id, ft.topic_title from posts as fp left join topics
as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]";
$check_verify = mysql_query($verify);
if (mysql_num_rows($check_verify) < 1) {
header("Location: topic_list.php");
exit;
} else {
$topic_id = mysql_result($check_verify,0,'topic_id');
$topic_title = stripslashes(mysql_result($check_verify,0,'topic_title'));
echo "
<html>
<head>
<title>Reply to Post</title>
</head>
<body>
<h1>Post your reply in $topic_title</h1>
<form method=POST action="$_SERVER[PHP_SELF]">
<p><strong>Your E-Mail Address:</strong><br>
<input type=text name="post_owner" size=40 maxlength=100>
<p><strong>Post Text:</strong><br>
<textarea name="post_text" rows=8 cols=40 wrap=virtual></textarea>
<input type=hidden name="op" value="addpost">
<input type=hidden name="topic_id" value="$topic_id">
<p><input type=submit name="submit" value="Add Post">
</form>
</body>
</html>";
};
} else if ($_POST[op] == "addpost") {
if ((!$_POST[topic_id]) || (!$_POST[post_text]) || (!$_POST[topic_owner])) {
header("Location: topic_list.php");
exit;
};
$add_post = "insert into posts values (' ', '$_POST[topic_id]', '$_POST[post_text]', now(), '$_POST[post_owner])";
mysql_query($add_post);
header("Location: showtopic.php?topic_id=$topic_id");
exit;
};
?>Ive messed with it for about 5-6 hours today and can't figure out whats wrong with it, please help...I'm only 15 and not very experienced with PHP or other server side languages so any assistance is appreciated, Thanks.
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]