<div>
<?php
include 'connect.php';
if(isset($_GET['id'])){
$page_id = $_GET['id'];
$select_query = "SELECT * FROM articles WHERE articles_id='$page_id'";
$run_query = mysql_query($select_query);
while($row=mysql_fetch_array($run_query)){
$articles_id = $row['articles_id'];
$articles_date = $row['articles_date'];
$articles_title = $row['articles_title'];
$articles_category = $row['articles_category'];
$articles_image = $row['articles_image'];
$articles_content = $row['articles_content'];
?>
<h3>
<a href="articlespage.php?id=<?php echo $articles_id; ?>">
<?php echo $articles_title; ?>
</a>
</h3>
<p><i>Published on <b><?php echo $articles_date; ?></b></i></p>
<center>
<img src="<?php echo $articles_image; ?>" width="300" height="250">
</center>
<p align="justify"><?php echo $articles_content; ?></p>
<hr>
<?php } } ?>
</div>
<div>
<form method="post" action="articlespage.php" enctype="multipart/form-data">
<table width="300" align="center" border="0">
<tr>
<td align="right">Name</td>
<td><input type="text" name="author"></td>
</tr>
<tr>
<td align="right">Email</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td align="right">Comment</td>
<td><textarea type="text" name="content" cols="30" rows="10"></textarea></td>
</tr>
<tr>
<td align="center" colspan="6"><input type="submit" name="submit" value="Publish Now"></td>
</tr>
</table>
</form>
<?php
include 'connect.php';
if (isset($_POST['submit'])){
// my problem is
// i cannot get the article_id to store it on com_art_id,
// the articles_id is already showing on url bar
// i have no idea how to place it on com_art_id
//// $com_art_id = $articles_id;
$comment_date = date('d-m-y');
$comment_name = $_POST['author'];
$comment_email = $_POST['email'];
$comment_content = $_POST['content'];
if ($comment_name=='' or $comment_email=='' or $comment_content==''){
echo '<center><b><font color="red">All fields are required.</font></b></center>';
}else{
$insert_query = "INSERT INTO comments(com_art_id, comment_date, comment_name,
comment_email, comment_content)
VALUES('$com_art_id', '$comment_date', '$comment_name', '$comment_email', '$comment_content')";
if(mysql_query($insert_query)){
//echo "<center>Submitted sucessfully.</center>";
header("Location: articlespage.php?");
}
}
}
?>
</div>