Hi,
When I hit the refresh page tab my application submits an empty form to the DB.
Can someone give me any pointers to stop this happening?
What code would you like to see?
Is this a common problem?
Cheers, Will/
Form Submits empty data when page refreshes
Moderator: General Moderators
- IceMetalPunk
- Forum Commoner
- Posts: 71
- Joined: Thu Jul 07, 2005 11:45 am
Just refreshing the page shouldn't submit a form. But if you have the form submit as soon as the page loads, then your problem is that in most browsers, refreshing the page clears the form. My suggestions:
1) Either check if the form is blank using JavaScript and don't submit it if it is.
OR
2) Don't have the form submit as soon as the page loads.
-IMP

1) Either check if the form is blank using JavaScript and don't submit it if it is.
OR
2) Don't have the form submit as soon as the page loads.
-IMP
My form must be submitting when the page reloads but NOT by design.
How can I debug this problem?
Basically I have a switch which executes the following code by default..
(I've removed a chunk of code to make it easier to read.
Any pointers would be rad!, Ta Will.
How can I debug this problem?
Basically I have a switch which executes the following code by default..
(I've removed a chunk of code to make it easier to read.
Any pointers would be rad!, Ta Will.
Code: Select all
function viewSAStockSummary() {
$paperCategoryId = isset($_POST['paperCategoryId']) ? $_POST['paperCategoryId'] : '';
$colloPaperName = isset($_POST['colloPaperName']) ? $_POST['colloPaperName'] : '';
$sql_add = "INSERT INTO ausapapersummary values ('','$paperCategoryId','$colloPaperName','$manufacturerName','$cpl','$stockId','$adhesiveId','$linerId','$supplierId','$availability', '$features', '$limitations','$productExamples','$suitabilityFoil','$suitabilityYellowLight','$suitabilityLabel','$suitabilityOpacity','$suitabilityBronze','$suitabilityScreen','$suitabilityIceBucket','','')";
mysql_query($sql_add) or die(mysql_error());
echo "<form name=\"addSummary\" method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<table onMouseover=\"changeto('lightgreen')\" onMouseout=\"changeback('white')\" class=\"sorttable\">\n";
echo "<td width=200px colspan=2 valign=top>Paper Category</td>";
echo "<td width=200px colspan=3>".paperCategory()."</td></tr>";
$second=array('Collo Paper Name','Manufactured Name','Computer Loopup Prefix');
$secondTitles = array('colloPaperName','manufacturerName','cpl');
for($x = 0; $x<count($second); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$second[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"4\"><input type=\"text\" name=\"".$secondTitles[$x]."\" size=\"50\" maxlength=\"100\"></td></tr>";
}
$displayStock = array('Face Stock','Adhesive','Liner');
$displayStockTitles = array(listFaceStock(),listAdhesive(),listLiner());
$displayButton = array(viewStock(),viewAdhesive(),viewLiner());
$displayButton2 = array(addFaceStock(),addAdhesive(),addLiner());
for($x = 0; $x<count($displayStock); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$displayStock[$x]."</td>\n\n";
echo "<td width=\"200px\" colspan=\"2\">$displayStockTitles[$x]</td>\n";
echo "<td width=50px>$displayButton[$x]</td>\n\n";
echo "<td width=50px>$displayButton2[$x]</td></tr>\n\n";
}
echo "</table></form>";
}