Hello guys! I'm trying to find a way to make a news script similar to that of yahoo which you can post comment. Mine on the other hand does not require login. I was able to make a basic script to it but the problem after the comment is posted. The post is inserted into the database but I need to retype the news id inorder to go back to the news article. I tried separating the pages but the header function does not accept variables. Is there a trick that you guys might share? I've attached the code below btw. Thank you very much in advance and god bless.
<body>
$id = $_GET['id'];
if (empty($id))
{
$id = $_POST['website_id'];
}
$mysql = "select * from news where nid = $id";
$result = mysql_query($mysql);
while ($row = mysql_fetch_array($result))
{
$newscontents = nl2br($row["newscontents"]);
$newstype = $row["newstype"];
echo("<br>");
echo("<p align=justify>" . $newscontents . "<p>");
}
$nccomments = "SELECT * FROM feedbacks, feedbacktype where feedbacks.fbacktypeid = '".$newstype."' AND feedbacktype.fbackidref = '".$newstype."'";
$ncresult = mysql_query($nccomments);
while ($ncrow = mysql_fetch_array($ncresult))
{
$ncusername = $ncrow["fbackusername"];
$ncemail = $ncrow["fbackemail"];
$ncfbackdate = $ncrow["fbackdate"];
$ncdate = $ncrow["fbackdate"];
$ncfbackdesc = $ncrow["fbackdescription"];
echo "<p>". $ncusername ."</p>";
echo "<p>". $ncemail ."</p>";
echo "<p>Posted: ". $ncfbackdate ."</p>";
echo "<p>". $ncfbackdesc ."</p>";
echo "<hr>";
}
?>
<br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="352" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="23"> </td>
<td><input type="hidden" name="website_id" value="<?php echo $id; ?>"></td>
</tr>
<tr>
<td height="23"> </td>
<td><input type="hidden" name="newstype" value="<?php echo $newstype; ?>"></td>
</tr>
<tr>
<td width="106" height="23">Name:</td>
<td width="240"><input type="text" name="username"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Comment:</td>
<td><textarea name="comments"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
if (!empty($username))
{
$username = $_POST['username'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$web_id = $_POST['website_id'];
}
else
{
$username = " ";
$email = " ";
$comments = " ";
$web_id = " ";
}
if (isset($username) && isset($email) && isset($comments)) {
add_comments($username, $email, $comments);
} function add_comments($u, $e, $c)
{
$insertcomments = "INSERT INTO feedbacks VALUES (NULL, '$u', '$e', curdate(), '$c', 1)";
$result = mysql_query($insertcomments);
mysql_close();
} ?>
</body>
</html>