Welke tabellen moet ik hiervoor aanmaken
PHP:
-- config.php --
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$database = "database_name";
?>
-- style.php --
<style>
a{ color:#006CA7; text-decoration: underline; }
a:visited{ color:#006CA7; text-decoration: underline; }
a:hover{ color:#0049E8; text-decoration: underline; }
BODY{ color: #000000; font-family: verdana; font-size: 7pt; }
TD{ color: #000000; font-family: verdana; font-size: 8pt; }
HR{ color: #000000; }
input{ font-size: 9pt; }
textarea{ font-size: 9pt; }
.ta{ border: 1px solid #000000; }
.subject{ background: #000000; color: #FFFFFF; font-family: verdana; font-size: 8pt; border: 1px solid #000000; }
.comment{ background: #DCDEDE; color: #000000; font-family: verdana; font-size: 8pt; border: 1px solid #000000; }
.newstext{ color: #000000; font-family: verdana; font-size: 8pt; }
.newstext1{ border: 1px solid #000000; }
.archive{ font-family: verdana; color: #000000; }
</style>
-- index.php --
<?php
include("config.php");
mysql_connect("$hostname","$username","$password");
mysql_select_db("$database");
if(isset($reply)) {
mysql_query("INSERT INTO reply(replyid,message,name) VALUES('$replyid','$mess','$name')") or die(mysql_error());
echo"<META HTTP-EQUIV='refresh' CONTENT='0; URL=$PHP_SELF?i=$replyid'>";
} elseif(isset($i)) {
include("style.php");
$select = mysql_query("SELECT * FROM news WHERE id = $i");
while($list = mysql_fetch_object($select)) {
echo TMP_HACK_FOR_CHAR
<center><a href=$PHP_SELF>Back to News Index</a></center><br>
<table width=400 cellpadding=4 cellspacing=0 align=center border=1 class=ta>
<tr><td class=subject>
<b>$list->subject</b>
</td></tr>
<tr><td class=newstext1>
<i>$list->date - by <a href=mailto:$list->email>$list->name</a></i><br>
<hr>
<span class=newstext>$list->message</span>
<hr><br><br>
";
}
$reactions = mysql_query("SELECT * FROM reply WHERE replyid = $i ORDER BY id DESC");
echo TMP_HACK_FOR_CHAR
<script language=javascript>
function validate() {
var temp
if (document.replyform.name.value==''){
alert('Name field is empty...')
return false
}
if (document.replyform.mess.value==''){
alert('Message field is empty...')
return false
} return true }
</script>
<b>Reactions:</b><br><br>
";
while($list = mysql_fetch_object($reactions)) {
$message = htmlspecialchars($list->message);
echo TMP_HACK_FOR_CHAR
<b>By:</b> $list->name<br>
$message<br><br>
";
}
echo TMP_HACK_FOR_CHAR
<form name=replyform onsubmit='return validate()' method=POST>
Name:<br>
<input type=text name=name maxlength=20 size=20><br>
Message:<br>
<textarea cols=30 rows=4 name=mess></textarea><br>
<input type=hidden name=replyid value=$i>
<input type=submit name=reply value=Reply>
</form>
</td></tr></table>
";
} elseif(isset($archive)) {
include("style.php");
$archive = mysql_query("SELECT * FROM news ORDER BY id DESC");
echo TMP_HACK_FOR_CHAR
<center>
<a href=$PHP_SELF>Back to News Index</a><br>
</center>
<br>
<table cellpadding=3 cellspacing=0 border=0 align=center class=archive><tr><td align=left><b>News Archive</b><br><br></td></tr>
";
while($list = mysql_fetch_object($archive)) {
$count = mysql_num_rows(mysql_query("SELECT * FROM reply WHERE replyid = $list->id"));
echo"<tr><td><i>$list->date</i></td><td> - </td><td><a href='$PHP_SELF?i=$list->id'>$list->subject</a> ($count Reactions)</td></tr>";
}
echo"</table>";
} else {
include("style.php");
$select = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 4");
while($list = mysql_fetch_object($select)) {
$result = mysql_num_rows(mysql_query("SELECT * FROM reply WHERE replyid = $list->id"));
echo TMP_HACK_FOR_CHAR
<table width=400 cellpadding=2 cellspacing=0 align=center border=1 class=ta>
<tr><td class=subject>
<b>$list->subject</b>
</td></tr>
<tr><td class=newstext1>
<i>$list->date - by <a href=mailto:$list->email>$list->name</a></i><br><br>
<span class=newstext>$list->message</span><br><br>
</td></tr>
<tr><td align=right class=comment>
<a href='$PHP_SELF?i=$list->id'>Add Comment</a> ($result Reactions)
</td></tr>
</table><br>
";
}
echo"<center><a href=index.php?archive>News Archive</a></center>";
}
?>
-- admin.php --
<?
include("config.php");
mysql_connect("$hostname","$username","$password");
mysql_select_db("$database");
if(isset($editreply)) {
mysql_query("UPDATE reply SET message = '$amessage',name = '$aname' WHERE id = $rid") or die(mysql_error());
header("Location: $PHP_SELF?do=editreply&i=$i");
} elseif(isset($editnews)) {
include("style.php");
mysql_query("UPDATE news SET message = '$emessage',subject = '$esubject',email = '$eemail',name = '$ename' WHERE id = $nid") or die(mysql_error());
echo"<center>The article has been edited..<br><a href=$PHP_SELF>Click here to return</a></center>";
} elseif(isset($putnews)) {
$date = date("d-m-Y g:i a");
$message = eregi_replace("n","<br>",$message);
mysql_query("INSERT INTO news(name,message,date,subject,email) VALUES('$name','$message','$date','$subject','$email')") or die(mysql_error());
echo"<META HTTP-EQUIV='refresh' CONTENT='0; URL=$PHP_SELF'>";
} elseif(isset($addnews)) {
include("style.php");
echo TMP_HACK_FOR_CHAR
<form method=post>
<table cellspacing=0 border=0 cellspacing=0 align=center>
<tr><td>Author: </td><td><input type=text name=name size=19 maxlength=20></td></tr>
<tr><td>E-Mail: </td><td><input type=text name=email size=19 maxlength=40></td></tr>
<tr><td>Subject: </td><td><input type=text name=subject size=19 maxlength=40></td></tr>
<tr><td>Message: </td><td><textarea name=message cols=38 rows=8></textarea><br>*HTML Enabled</td></tr>
<tr><td><input type=submit value='Add News' name=putnews></td></tr>
</table>
</form>
<br><center><a href=$PHP_SELF>Back to Admin Menu</a></center>
";
} elseif(isset($do)) {
if($do=="deleteall") {
mysql_query("DELETE FROM reply WHERE replyid = $i");
header("Location: $PHP_SELF");
} elseif($do=="deletereply") {
mysql_query("DELETE FROM reply WHERE id = $rid");
header("Location: $PHP_SELF?do=editreply&i=$i");
} elseif($do=="editreply") {
include("style.php");
$select = mysql_query("SELECT * FROM reply WHERE replyid = $i");
echo TMP_HACK_FOR_CHAR
<center><a href=$PHP_SELF>Back to Admin Menu</a></center><br><br>
<table align=center border=0 cellpadding=0 cellspacing=3><tr><td>
";
while($list = mysql_fetch_object($select)) {
echo TMP_HACK_FOR_CHAR
<form method=POST>
By:<br><input type=text value='$list->name' name=aname size=20><br>
Message<br>
<textarea cols=20 rows=3 name=amessage>$list->message</textarea><br>
<input type=hidden name=rid value='$list->id'>
<input type=submit value='Edit Reaction' name=editreply> <a href=$PHP_SELF?do=deletereply&rid=$list->id&i=$i>Delete Reaction</a>
</form>
";
}
echo"</td></tr></table>";
} elseif($do=="deletenews") {
mysql_query("DELETE FROM news WHERE id = $i");
mysql_query("DELETE FROM reply WHERE replyid = $i");
header("Location: $PHP_SELF");
} elseif($do=="editnews") {
include("style.php");
$select = mysql_query("SELECT * FROM news WHERE id = $i");
while($list = mysql_fetch_object($select)) {
echo TMP_HACK_FOR_CHAR
<form method=post>
<table cellspacing=0 border=0 cellspacing=0 align=center>
<tr><td>Author: </td><td><input type=text value='$list->name' name=ename size=19 maxlength=20></td></tr>
<tr><td>E-Mail: </td><td><input type=text value='$list->email' name=eemail size=19 maxlength=40></td></tr>
<tr><td>Subject: </td><td><input type=text value='$list->subject' name=esubject size=19 maxlength=40></td></tr>
<tr><td>Message: </td><td><textarea name=emessage cols=38 rows=8>$list->message</textarea><br>*HTML Enabled</td></tr>
<tr><td><input type=hidden value='$list->id' name=nid></td></tr>
<tr><td><input type=submit value='Edit News' name=editnews></td></tr>
</table>
</form>
<br><center><a href=$PHP_SELF>Back to Admin Menu</a></center>
";
}
}
} else {
include("style.php");
$select = mysql_query("SELECT * FROM news ORDER BY id DESC");
echo TMP_HACK_FOR_CHAR
<center>
<a href=index.php>Back to News Index</a><br><br>
<a href=$PHP_SELF?addnews>Add News</a>
</center><br><br>
<table align=center border=0 cellpadding=0 cellspacing=3>
";
while($list = mysql_fetch_object($select)) {
echo TMP_HACK_FOR_CHAR
<tr>
<td>''<b>$list->subject</b>'' </td>
<td><a href=$PHP_SELF?i=$list->id&do=deletenews>Delete Article</a> - <a href=$PHP_SELF?i=$list->id&do=editnews>Edit Article</a> - <a href=$PHP_SELF?do=editreply&i=$list->id>Edit Reactions</a> - <a href=$PHP_SELF?do=deleteall&i=$list->id>Delete All Reactions</a></td>
</tr>
";
}
echo"</table>";
}
?>