I thought this might help more.
This is my main script:
<?PHP
include "adminheader.php";
include "header.php";
if ($purpose == 'news') {
include "include/SQL_functions.php";
echo '
<table align="center">
<tr>
<td align="center" class="bj">Current News Article 1</td>
</tr>
<tr>
<td align="center">
<table class="d3" width="400" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<table summary="" class="d3" cellspacing="1" cellpadding="2">
<tr>
<td bgcolor="#acc6dd" width="75%" height="17" class="ne"> <b>. :</b> '.$article1[title].'</td>
<td bgcolor="#41729e" width="15%" height="17" class="ne"><div align="right"> '.$article1[date].' </div></td>
</tr>
<tr>
<td bgcolor="#ffffff" width="100%" height="17" class="ne" colspan="2">'.$article1[article].'</td>
</tr>
<tr>
<td bgcolor="#acc6dd" width="100%" height="17" class="ne" colspan="2"> <b>: .</b> posted by '.$article1[poster].'</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" class="bj"><a href="include/editnews.php?article=1">Edit Article 1</a></td>
</tr>
</table>
<br \>
<table align="center">
<tr>
<td align="center" class="bj">Current News Article 2</td>
</tr>
<tr>
<td align="center">
<table class="d3" width="400" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<table summary="" class="d3" cellspacing="1" cellpadding="2">
<tr>
<td bgcolor="#acc6dd" width="75%" height="17" class="ne"> <b>. :</b> '.$article2[title].'</td>
<td bgcolor="#41729e" width="15%" height="17" class="ne"><div align="right"> '.$article2[date].' </div></td>
</tr>
<tr>
<td bgcolor="#ffffff" width="100%" height="17" class="ne" colspan="2">'.$article2[article].'</td>
</tr>
<tr>
<td bgcolor="#acc6dd" width="100%" height="17" class="ne" colspan="2"> <b>: .</b> posted by '.$article2[poster].'</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" class="bj"><a href="include/editnews.php?article=2">Edit Article 2</a></td>
</tr>
</table>
';
}
?>
The edit articles link to this:
<?PHP
if ($article == '1') {
echo '
<table>
<tr><td>Edit Article 1</td></tr>
<tr><td>
<form action="newnews.php" method="post">
<table>
<tr>
<td class="news">Name:</td><td><input type="text" width="20" name="poster"></td>
</tr>
<tr>
<td class="news">Date: <br> <font size="-1">i.e. 1/23/2003</font></td><td><input type="text" width="10" value="00/00/0000" name="date"></td>
</tr>
<tr>
<td class="news">Article: <br> <font size="-1">225 Max Char.</font></td><td><textarea name="article" rows="4" cols="20"></textarea></td>
</tr>
<tr>
<td><input type="hidden" name="number" value="1"><input type="submit" value="Submit"></td>
</tr>
</form>
</table>
</tr></td>
</table>
';
}
if ($article == '2') {
echo '
<table>
<tr><td>Edit Article 2</td></tr>
<tr><td>
<table>
<form action="newnews.php" method="post">
<tr>
<td class="news">Name:</td><td><input type="text" width="20" name="poster"></td>
</tr>
<tr>
<td class="news">Date: <br> <font size="-1">i.e. 1/23/2003</font></td><td><input type="text" width="10" value="00/00/0000" name="date"></td>
</tr>
<tr>
<td class="news">Article: <br> <font size="-1">225 Max Char.</font></td><td><textarea name="article" rows="4" cols="20"></textarea></td>
</tr>
<tr>
<td><input type="hidden" name="number" value="2"><input type="submit" value="Post New News"></td>
</tr>
</form>
<table>
</tr></td>
</table>
';
}
?>
Then the form is handled with this:
<?php
$number = $_POST[number];
$poster = $_POST[poster];
$date = $_POST[date];
$article = $_POST[article];
if(!$number){echo 'This page has a error Please got back to the admin section and go through the "Change News Procedior" again. ';
}
if(!$poster){echo 'You forgot to enter your name. Please go back and fix this area. ';
}
if(!$date){echo "You didn't enter a date. Please go back and fix this area. ";
}
if(!$article){echo 'You forgot the article. Please go back and fix this area. ';
}
else {
include "SQL.php";
$query = "UPDATE news SET poster = '$poster', date = '$date', article = '$article' WHERE number = '$number'";
$result=mysql_query($query);
include "http://www.MYDOMAIN.com/admin/header.php";
}
?>
<script language="JavaScript">
self.location.href='http://www.MYDOMAIN.com/admin/index.php';
</script>
<table align="center">
<tr><td class="d3" align="center">Updates to the site have been completed.<br>You are now being sent to the admin homepage.</td></tr>
</table>
?>
I then get sent back to the main script. The first one. Should I maybe put the SQL queries in a function then call the function to the main script?