I need your help. Here is the code:
//Required Variables
$authorid = "3";
//Begin Script
if ($_POST['submit']=='Update Article') {
foreach ($_POST as $key=>$value) {
$_POST[$key] = htmlspecialchars(addslashes(trim($value)));
}
$action = "UPDATE news SET title = '$title', news = '$news' WHERE id = '$id'";
$query = mysql_query($action,$connection) or die ('Could Not Update Article because of an error: ' . mysql_error());
echo "Article $id successfully updated!<br>\n";
}
elseif (!isset($_POST['article_date']))
{
echo "<center>Please select the date of the article you want to edit by selecting a date from the drop down menu below";
echo "<form name=\"select_article_date\" action=\"update_news.php\" method=\"post\">";
echo "<select name=\"article_date\">";
//Start SQL Query To Pull Data
$query = mysql_query ("SELECT DISTINCT(DATE_FORMAT(date, '%m/%d/%Y')) AS disp_date, DATE_FORMAT(date, '%Y-%m-%d') AS date_value FROM news WHERE authorid='$authorid' ORDER BY date DESC");
while ($row = mysql_fetch_array($query)) {
echo '<option value="' . $row['date_value'] . '">' . $row['disp_date'] . "</option>\n";
}
//Close HTML
echo "<br>";
echo "<input name=\"submit\" type=\"submit\" value=\"Select Article Date\">";
echo "</select>";
echo "</form>";
echo "</center>";
}
elseif (!isset($_POST['article']))
{
echo "<center>Please select an article to edit by selecting an article from the drop down menu below";
echo "<form name=\"select_article\" action=\"update_news.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"article_date\" value=\"$article_date\">";
echo "<select name=\"article\">";
//Start SQL Query To Pull Data
$query = mysql_query ("SELECT title FROM news WHERE authorid = '$authorid' AND DATE_FORMAT(date, '%Y-%m-%d') = '$article_date' ORDER BY title ASC");
while ($row = mysql_fetch_array($query))
{
$title = $row['title'];
//List the options for the list field
echo "<option>";
echo $title;
echo "</option>";
}
//Close HTML
echo "<br>";
echo "<input name=\"submit\" type=\"submit\" value=\"Select Article\">";
echo "</select>";
echo "</form>";
echo "</center>";
}
//if all succedds
elseif (isset($_POST['article']) && isset($_POST['article_date']))
{
echo "<center>Please edit the article by using the fields below";
echo "<form name=\"edit_article\" action=\"update_news.php\" method=\"post\">\n";
// Note: you had both the hidden fields named 'article_date'
echo "<input type=\"hidden\" name=\"article_date\" value=\"$article_date\">\n";
echo "<input type=\"hidden\" name=\"article\" value=\"$article\">\n";
//SQL query to display article in the textbox
$query = mysql_query ("SELECT id,title,news FROM news WHERE authorid = '$authorid' AND date = '$article_date' AND title = '$article'") or die ("ERROR");
while ($row = mysql_fetch_array($query) or die ("ERROR 2"))
{
$id = $row ['id'];
$title = $row ['title'];
$news = $row ['news'];
echo "You are editing the article: <B>$title</B>.";
echo "<BR>";
echo "The article's id is <B>$id</B>";
echo "<br>";
echo "The link to the article is <a href=\"http://www.onlyonxbox.net/news.php?id=$id>[url]http://www.onlyonxbox.net/news.php?id=[/url]$id</a>.";
echo "
<table width=\"600px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td align=\"left\" valign=\"top\">
<p>
Title:
<input name=\"title\" type=\"text\" value=\"$title\">
<input name=\"id\" type=\"hidden\" value=\"$id\">
</p>
<br>
<p>
Article:
<textarea name=\"news\" cols=\"100\" rows=\"10\">$news</textarea>
</p>
<p align=\"center\">
<input name=\"submit\" type=\"submit\" value=\"Update Article\">
</p>
</td>
</tr>
</table>
";
}
//Close HTML
echo "</form>";
echo "</center>";
}
After doing everything and getting to "Please edit the article by using the fields below" (line 70)... that message is all I see - no form, no nothign... what's up?
!PLEASE HELP QUICK!
Sharif