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:
<?php
include("globalfn.php");
//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%">
<? 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>
<? $sql = "SELECT * FROM tbl_announce";
$result = put_result($sql);
while($row = mysql_fetch_object($result)) { ?>
<tr onMouseOut="this.bgColor = ''" onMouseOver="this.bgColor = '#CCCCCC';">
<td valign="top"><? echo($row->title); ?></td>
<td valign="top"><? echo(date("M-d-Y", strtotime($row->dt_created))); ?></td>
<td valign="top"><? if ($row->status == 1) { echo("Online"); } else { echo("Offline"); }?></td>
<td valign="top" align="center" width="50"><a href="ann_edit.php?ann_id=<? echo($row->ann_id); ?>" class="textgoldsmall">edit</a></td>
<td valign="top" align="center" width="50"><a href="ann_list.php?ann_id=<? echo($row->ann_id); ?>&intdelete=1" onClick="return areyousure()">delete</a></td>
</tr>
<? } ?>
</table></td></tr>
</table>
</body>
</html>
the edit page is the following:
<?php
include("globalfn.php");
$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";
put_result($sql);
header("Location: ann_list.php");
}
//Select Incentive
$sql = "SELECT * 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">
<? 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="<? echo($row->title); ?>" maxlength="200"></td>
</tr>
<tr>
<td valign="top">Content: </td>
<td><textarea name="content" rows="20" cols="50"><? echo(repl_br($row->content)); ?></textarea></td>
</tr>
<tr>
<td>Status: </td>
<td>
<input type="radio" name="status" value="1" <? if ($row->status == 1) { echo("checked"); } ?>> Online
<input type="radio" name="status" value="2" <? 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="<? echo($ann_id) ?>">
</table>
</form>
</body>
</html>
Please help!!!