Advertisement
Advertisement
| 06.20.2008 at 03:11PM PDT, ID: 23503761 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: |
<?php
include 'config.php';
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
if(isset($_GET['del']))
{
$query = "DELETE FROM projects WHERE id = '{$_GET['del']}'";
mysql_query($query) or die('Error : ' . mysql_error());
// then remove the cached file
$cacheDir = dirname(__FILE__) . '/cache/';
$cacheFile = $cacheDir . '_' . $_GET['id'] . '.html';
@unlink($cacheFile);
// and remove the index.html too because the file list
// is changed
@unlink($cacheDir . 'index.html');
// redirect to current page so when the user refresh this page
// after deleting an article we won't go back to this code block
//header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
?>
<html>
<head>
<title>Admin Page For MGsoft Project Management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function delArticle(id, projectname)
{
if (confirm("Are you sure you want to delete '" + projectname + "'"))
{
window.location.href = 'cms-admin.php?del=' + id;
}
}
</script>
</head>
<body>
<?php
$query = "SELECT projectname, dateinput, status, content FROM projects ORDER BY id";
$result = mysql_query($query) or die('Error : ' . mysql_error());
?>
<table width="600" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999">
<tr align="center" bgcolor="#CCCCCC">
<td width="500"><strong>Projectname</strong></td>
<td width="150"><strong>Action</strong></td>
</tr>
<?php
while(list($id, $projectname, $dateinput, $status, $content) = mysql_fetch_array($result, MYSQL_NUM))
{
?>
<tr bgcolor="#FFFFFF">
<td width="500">
<?php echo $id;?>
</td>
<td width="150" align="center">
<a href="show2.php?id=<?php echo $content;?>" target="_blank">view</a>
| <a href="cms-edit.php?id=<?php echo $id;?>">edit</a>
| <a href="javascript:delArticle('<?php echo $id;?>',
'<?php echo $projectname;?>');">delete</a></td>
</tr>
}
mysql_close();
?>
</table>
<p align="center"><a href="cms-add.php">Add an article</a></p>
</body>
</html>
|