Page 1 of 1
Form Submits empty data when page refreshes
Posted: Sun Jul 10, 2005 2:58 am
by facets
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/
Posted: Sun Jul 10, 2005 9:05 am
by IceMetalPunk
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

Posted: Sun Jul 10, 2005 2:13 pm
by pilau
Hi, I'm new, both to DevNet and to PHP.
As I was reading this post, I was wondering - coudn't it be a POST issue?
Posted: Wed Jul 20, 2005 3:42 am
by facets
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.
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>";
}