alright so I have a script to manage articles on my website and I was wondering if there is any easier way...or a way to use less code for checking to see if all the variables have been input. currently I'm using if...else statements to check, but it repeats form code over and over and that gets big quickly...I know I could make an if...else to check if the fields are blank...anyways...here is the code
// Initial state of Adding an Article
if ($article == "" && $article_title == "") {
echo "<form action='$PHP_SELF?content=add' method='post'>
Article Name: <input type='text' name='article_title'><br>
Article Section:<select name='article_sec'>";
$result = mysql_query("SELECT article_sec FROM mfkr_sec ORDER BY article_sec ASC");
while ($row = mysql_fetch_object($result))
{
echo "<option>".$row->article_sec."</option>";
}
echo "</select><br>
Article:<br>
<textarea name='article' rows='60' cols='65' wrap='virtual'></textarea><br>
<input type='image' src='../images/submit.gif' name='submit' value='Submit'>
</form>";
// If article title is blank then page is reloaded
} else if ($article_title == "" && $article != "")
{
echo "<font color='#ffffff'><b>*Article Name was not Entered</b></font><br><br>";
echo "<form action='$PHP_SELF?content=add' method='post'>
<font color='#ffffff'>*Article Name:</font><input type='text' name='article_title'><br>
Article Section:<select name='article_sec'>";
$result = mysql_query("SELECT article_sec FROM mfkr_sec ORDER BY article_sec ASC");
while ($row = mysql_fetch_object($result))
{
echo "<option>".$row->article_sec."</option>";
}
echo "</select><br>
Article:<br>
<textarea name='article' rows='60' cols='65' wrap='virtual'>$article</textarea><br>
<input type='image' src='../images/submit.gif' name='submit' value='Submit'>
</form>";
// If article content is blank then page is reloaded
} else if ($article_title != "" && $article == "")
{
echo "<font color='#ffffff'><b>*Article was not Entered</b></font><br><br>";
echo "<form action='$PHP_SELF?content=add' method='post'>
Article Name: <input type='text' name='article_title' value='$article_title'><br>
Article Section:<select name='article_sec'>";
$result = mysql_query("SELECT article_sec FROM mfkr_sec ORDER BY article_sec ASC");
while ($row = mysql_fetch_object($result))
{
echo "<option>".$row->article_sec."</option>";
}
echo "</select><br>
<font color='#ffffff'>*Article:</font><br>
<textarea name='article' rows='60' cols='65' wrap='virtual'></textarea><br>
<input type='image' src='../images/submit.gif' name='submit' value='Submit'>
</form>";
}
so yeah...long and annoying