Hi everyone,
I am Re-writing a script that allows me to edit content in the database. I am trying to write it with global varibles turned off for security reasons. But I keep getting an error on the page so the script will not work. With global set to on the script still displays an error but it works.
Please help me before I go insane.
ERROR
-------------------------
Notice: Undefined variable: action in C:\Program Files\Apache Group\Apache2\htdocs\site\about1.php on line 5
Code:
<?
include("inc/conn.php");
if($action=="Modify Content")
{
if ($upfile_name != "")
{
$sql_delete = "Select upfile FROM about
WHERE id = \"1\"
";
$result_delete = @mysql_query($sql_delete,$connection) or die("Couldn't execute query.");
while ($row_delete = mysql_fetch_array($result_delete))
{
$upfile_delete = $row_delete['upfile'];
#Try to delete the image if there is one.....
if ($upfile_delete <> "")
{
$file = "$upfile_delete";
unlink("aboutimage/$file");
}
}
move_uploaded_file($upfile, "aboutimage/$upfile_name")
or die("The file name you chose for your image is already being used, please use the back button on your browser, change the image file name and try adding it again.");
$setlist = "content = \"$content\", upfile = \"$upfile_name\"";
}
else
{
$setlist = "content = \"$content\"";
}
$sql = "UPDATE about SET $setlist WHERE id = '1'";
if(@mysql_query($sql))
{
header("Location: admin_menu.php");
exit;
}
else
{
header("Location: error.php");
exit;
}
}
$sql99 = "SELECT *
FROM about
WHERE id = \"1\"
";
$result99 = @mysql_query($sql99,$connection) or die("Couldn't execute query.");
while ($row99 = mysql_fetch_array($result99))
{
$id = $row99['id'];
$content = $row99['content'];
$upfile = $row99['upfile'];
}
?>
<blockquote>
<table bgcolor="#D7D7D7" border=1>
<tr>
<td>
<FORM METHOD=POST ACTION="about1.php" ENCTYPE="multipart/form-data">
<table>
<tr>
<td colspan=2><span class="maintext"><B>About</B></span></td>
</tr>
<tr>
<td valign=top><span class="maintext"><B>Content:</B></span></td>
<td><textarea NAME="content" cols=55 rows=20><? echo $content; ?></textarea></td>
</tr>
<tr>
<td colspan=2><span class="maintext"><B>Current File: </B><? echo $upfile; ?></span></td>
</tr>
<tr>
<td><span class="maintext"><B>File:</B></span></td>
<td><INPUT TYPE="file" NAME="upfile" size=35></td>
</tr>
<tr>
<td colspan=2 align=center><INPUT TYPE="submit" name="action" value="Modify Content"></td>
</tr>
</table>
</FORM>
</td>
</tr>
</table>
</blockquote>