I have a project which has been working quite well for a long time. Suddenly, the "admin" page for that site I made no longer work? It has a portion where the website admin (who is not a web developer or know nothing about php or mysql) can change information, upload picture, etc on an interface I created specially for him.
Problem is, it is no longer functioning lately. All the changes made does not change anything in the database anymore? what could possibly be wrong? attached are the files involved:
LIST PAGE
<?php
include("globalfn.php");
// decalres $intdelete, $ann_id
$intdelete = $_GET["intdelete"]; //get action variable from link
$ann_id = $_GET["ann_id"]; //get action variable from link
//Check if logged-in
//$adminusername = $_COOKIE['adminusername'];
//$adminpassword = $_COOKIE['adminpassword'];
//if(trim(@$adminusername)=="" and trim(@$adminpassword)=="") {
// header("Location: login.php");
//}
//Delete
if(@$intdelete == 1) {
$sql = "DELETE FROM tbl_announce WHERE ann_id=$ann_id";
put_result($sql);
}
?>
<html>
<head>
<title>admin</title>
<link rel="stylesheet" type="text/css" href="admin.css">
<script language="JavaScript" type="text/javascript">
<!--
function areyousure() {
ask = confirm("Are you sure you want to delete this entry?");
if(!ask) { return false; }
}
//-->
</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<?php include("header_admin.php"); ?>
<tr><td><b>List of Announcements</b></td></tr>
<tr><td><a href="home.php">[home]</a> | <a href="ann_add.php">[add announcements]</a></td></tr>
<tr><Td> </Td></tr>
<tr><td><table border="1" cellpadding="2" cellspacing="2" width="100%">
<tr>
<td valign="top"><b>Title</b></td>
<td valign="top"><b>Date Created</b></td>
<td valign="top"><b>Status</b></td>
<td valign="top" align="center" width="50"> </td>
<td valign="top" align="center" width="50"> </td>
</tr>
<?php $sql = "SELECT title, ann_id, status FROM tbl_announce";
$result = put_result($sql);
while($row = mysql_fetch_object($result)) { ?>
<tr onMouseOut="this.bgColor = ''" onMouseOver="this.bgColor = '#CCCCCC';">
<td valign="top"><?php echo($row->title); ?></td>
<td valign="top"><?php echo(date("M-d-Y", strtotime($row->dt_created))); ?></td>
<td valign="top">
<?php
//if ($row->status == 1) { echo("Online"); } else { echo("Offline"); }
//thanks bradgrafelman
echo ($row->status == 1 ? "Online" : "Offline"); ?>
</td>
<td valign="top" align="center" width="50"><a href="ann_edit.php?ann_id=<?php echo($row->ann_id); ?>" class="textgoldsmall">edit</a></td>
<td valign="top" align="center" width="50"><a href="ann_list.php?ann_id=<?php echo($row->ann_id); ?>&intdelete=1" onClick="return areyousure()">delete</a></td>
</tr>
<?php } ?>
</table></td></tr>
</table>
</body>
</html>
EDIT PAGE:
<?php
include("globalfn.php");
$ann_id = (isset($_GET['ann_id']) ? $_GET['ann_id'] : '');
//Check if logged-in
//$adminusername = $_COOKIE['adminusername'];
//$adminpassword = $_COOKIE['adminpassword'];
//if(trim(@$adminusername)=="" and trim(@$adminpassword)=="") {
// header("Location: login.php");
//}
if($REQUEST_METHOD == "POST") {
$currdate = date("Y-m-d");
$content = repl_enter($content);
// $sql = "UPDATE tbl_announce SET title = '$title', content = '$content', dt_created = '$currdate', status = $status WHERE ann_id = $ann_id";
// thanks bradgrafelman
$sql = sprintf("UPDATE tbl_announce SET title='%s', content='%s',"
. "dt_created=CURDATE(), status=%d WHERE ann_id=%d",
mysql_real_escape_string($_POST['title']),
mysql_real_escape_string($_POST['content']),
$_POST['status'],
$ann_id
);
put_result($sql);
header("Location: ann_list.php");
}
//Select Incentive
$sql = "SELECT title, ann_id, content, status FROM tbl_announce WHERE ann_id = '$ann_id'";
$result = put_result($sql);
$row = mysql_fetch_object($result);
?>
<html>
<head>
<title>admin</title>
<link rel="stylesheet" type="text/css" href="admin.css">
<script language="JavaScript" type="text/javascript">
<!--
function cmdSubmit() {
if (document.frm.title.value == "") {
alert("Please key in Title");
document.frm.title.focus();
document.frm.title.select();
return false;
}
if (document.frm.content.value == "") {
alert("Please key in Content");
document.frm.content.focus();
document.frm.content.select();
return false;
}
document.frm.submit();
}
//-->
</script>
</head>
<body>
<form action="ann_edit.php" name="frm" METHOD="POST">
<table border="0" cellspacing="0" cellpadding="0">
<?php include("header_admin.php"); ?>
<tr><td colspan="2"><b>Edit Announcement</b></td></tr>
<tr><td colspan="2"><a href="home.php">[home]</a> | <a href="ann_list.php">[back]</a></td></tr>
<tr><td> </td></tr>
<tr>
<td>Title: </td>
<td><input type="text" name="title" size="60" value="<?php echo($row->title); ?>" maxlength="200"></td>
</tr>
<tr>
<td valign="top">Content: </td>
<td><textarea name="content" rows="20" cols="50"><?php echo(repl_br($row->content)); ?></textarea></td>
</tr>
<tr>
<td>Status: </td>
<td>
<input type="radio" name="status" value="1" <?php if ($row->status == 1) { echo("checked"); } ?>> Online
<input type="radio" name="status" value="2" <?php if ($row->status == 2) { echo("checked"); } ?>> Offline
</td>
</tr>
<tr>
<td> </td>
<td><br><input type="button" name="btnsave" value="Submit" onClick="cmdSubmit(); return false;"></td>
</tr>
<input type="hidden" name="ann_id" value="<?php echo($ann_id) ?>">
</table>
</form>
</body>
</html>
Please help!!!
:mad: