From 8bf1358efdd91ae3c41e01924cd30c62a3bbdefb Mon Sep 17 00:00:00 2001 From: Ian Weller Date: Sat, 12 Jul 2008 14:28:10 -0500 Subject: [PATCH] Fixed a bug where empty quotes could be submitted Simply hitting Submit without entering any data could still post a new quote, with zero content. This has been fixed in submit.php and submitbulk.php. In addition, $footer wasn't being printed at the end of submitbulk.php, so now it is. --- submit.php | 8 ++++++++ submitbulk.php | 26 +++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/submit.php b/submit.php index 2e7e56f..8e0dd73 100644 --- a/submit.php +++ b/submit.php @@ -28,6 +28,14 @@ $quote_lt = ereg_replace('<', '<' , $quote); $quote_gt = ereg_replace('>', '>' , $quote_lt); $quote_lb = trim($quote_gt); +// Check to make sure we have contents being put in the database, otherwise +// an empty quote will occur +if (strlen($quote_lb) <= 0) { + echo "

No quote was submitted.

"; + echo $footer; + exit(); +} + // Insert into database as new. We leave out ID number cause the // database will autoincrement that field by itself. diff --git a/submitbulk.php b/submitbulk.php index f2629fd..06e7a21 100644 --- a/submitbulk.php +++ b/submitbulk.php @@ -37,6 +37,12 @@ foreach($kaboom as $quote) { $quote_gt = ereg_replace('>', '>' , $quote_lt); $quote_lb = trim($quote_gt); + // Check to make sure we have contents being put in the database, otherwise + // an empty quote will occur + if (strlen($quote_lb) <= 0) { + continue; + } + // Insert into database as new. We leave out ID number cause the // database will autoincrement that field by itself. @@ -47,13 +53,19 @@ foreach($kaboom as $quote) { } $qcount = count($ids); -echo "

$qcount quotes posted

"; -echo "

The following $qcount quotes were added:

"; -foreach($ids as $id) { - $idstrs[] = "$id"; +if ($qcount == 0) { + echo "

No quote was submitted.

"; +} else { + echo "

$qcount quotes posted

"; + echo "

The following $qcount quotes were added:

"; + foreach($ids as $id) { + $idstrs[] = "$id"; + } + $quotes = implode(' ', $idstrs); + echo "

$quotes

"; + echo "

Go back to the QDB

"; } -$quotes = implode(' ', $idstrs); -echo "

$quotes

"; -echo "

Go back to the QDB

"; + +echo $footer; ?> -- 2.11.4.GIT