header.php
Code: Select all
<?php
$insight_name = "Insight";
$insight_slogan = "Racing";
$theme = "insight";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
. "<link href=\"index.css\" rel=\"stylesheet\" type=\"text/css\" />\n"
. "<head>\n"
. "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
. "<title>" . $insight_name . " :: " . $insight_slogan . "</title>\n"
. "<script language=\"javascript\" type=\"text/javascript\" src=\"../js/collapsibletable.js\"></script>\n"
. "<script language=\"javascript\" type=\"text/javascript\" src=\"../js/delnews.js\"></script>\n"
. "<link id=\"text-css\" href=\"themes/" . $theme . "/style.css\" rel=\"stylesheet\" rev=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n"
. "</head>\n\n"
. "<body onload=\"init()\">\n\n"
. "<a name=\"top\"></a>\n\n";
?>Code: Select all
<?php
include("includes/constants.php");
$sql=mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db(DB_NAME, $sql) or die ("I cannot select the database '$dbname' because: " . mysql_error());
$news = mysql_query("SELECT * FROM insight_news ORDER BY nid DESC") or die ('Error : ' . mysql_error());
while($fetchnews = mysql_fetch_array($news)) {
$id = $fetchnews['nid'];
$title = $fetchnews['title'];
$author = $fetchnews['author'];
$authorid = $fetchnews['author_id'];
$text = $fetchnews['text'];
$month = $fetchnews['month'];
$day = $fetchnews['day'];
$year = $fetchnews['year'];
$bbcodeoff = $fetchnews['bbcodeoff'];
$smileyoff = $fetchnews['smileyoff'];
echo "<div style=\"padding-bottom:15px\">\n"
. "<table cellspacing=\"0\" width=\"100%\">\n";
include("themes/insight/colors.php");
echo "<thead><tr bgcolor=\"" . $bgcolor1 . "\"><td class=\"tnews\"><span style=\"float:right\">";
if(isset($_GET['delnews']))
{
$query = mysql_query("DELETE FROM insight_news WHERE nid = '{$_GET['delnews']}'")or die('Error : ' . mysql_error());
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
echo "<a href=\"javascript:delnews('$fetchnews->$id','$fetchnews->$title')\"><img border=\"0\" src=\"themes/insight/images/delete.png\" alt=\"Delete\" /> </a>";
echo "<a href=\"#top\" onclick=\"toggleItem('" . $title . "_" . $id . "')\"><img border=\"0\" src=\"themes/insight/images/collapseobj.png\" alt=\"toggle\" /></a></span><img src=\"themes/insight/images/ticon.png\" alt=\"table icon\" /> " . $title . "</td></tr></thead>\n"
. "<tbody id=\"" . $title . "_" . $id . "\">\n"
. "<tr bgcolor=\"" . $bgcolor2 . "\"><td class=\"thead\">" . $date . " - " . $time . " - by " . $author . "</td></tr>\n"
. "<tr bgcolor=\"" . $bgcolor3 . "\" style=\"color:#FFF\"><td><table width=\"100%\"><tr bgcolor=\"" . $bgcolor4 . "\" style=\"color:#000\"><td>\n"
. "<div id=\"ttext\" style=\"padding-top:5px; padding-bottom:5px; padding-left:5px; padding-right:5px; width:100%\">" . $text . "</div>\n"
. "</td></tr></table><span style=\"color:#CCC\">...[Read More]</span></td></tr>\n";
echo "<tr bgcolor=" . $bgcolor1 . "><td class=\"tfooter\">Hello</td></tr></tbody></table>\n"
. "</div>\n";
};
?>Code: Select all
function delnews(nid, title)
{
if (confirm("Are you sure you want to delete '" + title + "'"))
{
window.location.href = 'index.php?delnews=' + nid;
}
}Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/insight/public_html/includes/header.php:18) in /home/insight/public_html/modules/news/index.php on line 36
Code: Select all
header('Location: ' . $_SERVER['HTTP_REFERER']);So can somebody please tell me what I've done wrong? How do I get it to reload the page once I've clicked the delete button and how do I get it to show all the content on the page? And why isn't it deleting the table from the database?