<?php
///////////////// eerst contact maken met de database //////////////////////
$db = "mijn_database";
$dbuser = "user";
$dbpass = "pass";
$dbhost = "localhost";
$dbh=mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db( "$db" ) or trigger_error( mysql_error() );
//////////////// contact gemaakt met de database /////////////////
$article=$_GET['article'];
if($_GET['soort']=='reply'){
//////////////// een pagina voor het maken van de comments ////////////
$reply=$_GET['reply'];
$article_id=$_GET['article_id'];
echo "<center><h3>Comment</h3>";
echo "<table width=85% border=0><form method='POST' action='index.php?article_id=$article_id&soort=post'>";
echo "<input type='hidden' name='article_id' value='$article_id'>";
echo "<tr align='center'><td>Post<td><TEXTAREA name='post_text' cols='60' rows='6'></TEXTAREA>";
echo "<tr align='center'><td><td><input type='submit' name='post' value='Post'><input type='hidden' name='post' value='post'></form>";
echo "</table>";
//////////////// einde pagina voor het maken van de comments ////////////
}else{
//////////////// een pagina voor het laten zien van de comments ////////////
//////////////// eerst een klein stukje voor het posten /////////////
if($_GET['soort']='post' and $_POST['post']='post' and $_POST['post_text']!=''){
$article_id=$_POST['article_id'];
$post_text=$_POST['post_text'];
$time=time();
$Query_post_in_forum="INSERT INTO `comments` (`ID`, `article_id`, `poster`, `post`, `time`) VALUES ('','$article_id','".$_SESSION['user_id']."', '$post_text', '$time')";
$res_post_in_forum=mysql_query($Query_post_in_forum);
$fout=mysql_errno($dbh);
if ($fout != 0) {
$fout=mysql_error($dbh);
echo "<font color=\#FF0000\"><center>An error occured. This is the error message:$fout. Error code: 1 <br> Sorry for the inconvenience.<br><br>The taridge admin team.</center></font>";
mysql_close($dbh);
echo "</body></html>";
exit;
}
}
////////////// einde posten, nu de pagina /////////////
$article_id=$_GET['article_id'];
$query_select_post="SELECT * FROM `comments` where `article_id`='$article_id'";
$res_select_post=mysql_query($query_select_post);
$fout=mysql_errno($dbh);
if ($fout != 0) {
$fout=mysql_error($dbh);
echo "<font color=\#FF0000\"><center>An error occured. This is the error message:$fout. <br> Sorry for the inconvenience.<br><br>The taridge admin team.</center></font>";
mysql_close($dbh);
echo "</body></html>";
exit;
}
$aantal_posts_made=mysql_num_rows($res_select_post);
if($aantal_posts_made!=0){
echo "<table>";
for($tellingnummer_post=0;$tellingnummer_post<$aantal_posts_made;$tellingnummer_post++){
$row_select_posts=mysql_fetch_assoc($res_select_post);
$poster=$row_select_posts['poster'];
if($poster==''){
$poster='Anonymous';
}
$post=$row_select_posts['post'];
echo "<tr align='center'><td width=22% style='border: 1px solid #C0C0C0;'>Poster: $poster<td style='border: 1px solid #C0C0C0;'>$post";
}
echo "</table>";
}else{
echo "No post found.";
}
echo "<br><a href='index.php?article_id=$article_id&soort=reply'>Reply</a>";
}
////////////////// einde van pagina voor het laten zien van de comments ///////////
?>