Hi Gang,
I'm having some trouble with submits. I have seven on one page.
The HTML 'looks' correct but something is going astray.
For example instead of execting the 'viewFaceStock' function when hitting the 'View Face Stock Specs' button it sets 'commented' and writes to the DB. But when I hit the 'addSummary' button it does nothing.
I've included only a snip of the code, i hope it's enough.
Sorry in advance for the huge amount of code...
Any help would be rad!
Tia, Will.
From Functions :
function listCat() {
$sql_query = mysql_query("SELECT paperCategory, paperCategoryId FROM aupapercategory");
$output = "<select name=\"paperCategoryId\">";
$output .= "<option value=\"\">-- Select Option --</option>";
while(list($catname, $paperCategoryId)=mysql_fetch_array($sql_query)) {
$catname = stripslashes($catname);
$output .= "<option value=\"$paperCategoryId\">$catname</option>";
}
$output .= "</select>";
mysql_free_result($sql_query);
return $output;
}
Main Code lines :
<?
include "../includes/functions.inc";
include "../includes/common_db.inc";
$link_id = db_connect($db_materials);
// Set action Variable
$action = isset($_GET['action']) ? $_GET['action'] : '';
// Set Up Submit
// better yet, use !empty() to make sure your variable has atleast a value.
if (isset($_POST['addSummary'])) {
echo '<pre>'; print_r($_POST); echo "<h1>Submitted to DB</h1><br>"; echo "</pre>";
}
if (isset($_POST['viewFaceStock'])) {view($_POST['stockId']);}
if (isset($_POST['viewAdhesive'])) {viewAdhesives($_POST['adhesiveId']);}
if (isset($_POST['viewLiner'])) {viewLiners($_POST['linerId']);}
if (isset($_POST['addFaceStock'])) {addFaceStock();}
if (isset($_POST['addAdhesive'])) {addAdhesive();}
if (isset($_POST['addLiner'])) {addLiner();}
// Window POPUP Function
function view($stockId) {
echo "<script language=\"javascript\">var newWindow = window.open
('".$_SERVER['PHP_SELF']."?action=viewFaceStock&stockId=".$stockId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')</script>";
}
function viewLiners($linerId) {
echo "<script language=\"javascript\">var newWindow = window.open
('".$_SERVER['PHP_SELF']."?action=viewLiner&linerId=".$linerId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')</script>";
}
function viewAdhesives($adhesiveId) {
echo "<script language=\"javascript\">var newWindow = window.open
('".$_SERVER['PHP_SELF']."?action=viewAdhesive&adhesiveId=".$adhesiveId."','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=550')</script>";
}
// Functions to open new 'ADD' windows.
function addFaceStock() {
echo "<script language=\"javascript\">var newWindow = window.open
('addFaceStock.php','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=600')</script>";
}
function addAdhesive() {
echo "<script language=\"javascript\">var newWindow = window.open
('addAdhesive.php','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=570')</script>";
}
function addLiner() {
echo "<script language=\"javascript\">var newWindow = window.open
('addLiner.php','','scrollbars=yes,status=yes,windowX=10,windowY=10,width=440,height=500')</script>";
}
function fnAddAdhesive() {
}
function fnAddLiner() {
}
function viewFaceStockSummary() {
$tpl['title'] = "Australian Self Adhesive Paper Summary";
$tpl['content'] = "";
if (isset($_POST['viewFaceStock'])) {view($_POST['stockId']);}
if (isset($_POST['viewAdhesive'])) {viewAdhesives($_POST['adhesiveId']);}
if (isset($_POST['viewLiner'])) {viewLiners($_POST['linerId']);}
if(isset($_GET['commented']))
{
echo('Your comment has been posted.');
$paperCategoryId = $_GET['paperCategoryId'];
$colloPaperName = $_GET['colloPaperName'];
$manufacturerName = $_GET['manufacturerName'];
$cpl = $_GET['cpl'];
$stockId = $_GET['stockId'];
$adhesiveId = $_GET['adhesiveId'];
$linerId = $_GET['linerId'];
$supplierId = $_GET['supplierId'];
$availability = $_GET['availability'];
$features = $_GET['features'];
$limitations = $_GET['limitations'];
$productExamples = $_GET['productExamples'];
$sql_add = "INSERT INTO ausapapersummary values('','$paperCategoryId','$colloPaperName','$manufacturerName','$cpl','$stockId','$adhesiveId','$linerId','$supplierId','$availability', '$features', '$limitations','$productExamples','','','','','','','','','')";
mysql_query($sql_add) or die(mysql_error());
}
else {
?>
<form method='get' action='<? echo $_SERVER['PHP_SELF']; ?>'>
<input type='hidden' name='commented' value='set'>
<?
echo "<table class=\"materials\">";
$first=array('Paper Category');
$firstTitles = array(listCat());
for($x = 0; $x<count($first); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$first[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"4\">$firstTitles[$x]</td></tr>\n";
}
$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>\n";
}
$third=array('Face Stock','Adhesive','Liner','Supplier');
$thirdTitles = array(listFaceStock(),listAdhesive(),listLiner(),listSupplier());
$thirdType = array('submit','submit','submit','');
$thirdName = array('viewFaceStock','viewAdhesive','viewLiner','');
$thirdValue = array('View Face Stock Specs','View Adhesive Specs','View Liner Specs','');
$thirdType1 = array('submit','submit','submit','');
$thirdName1 = array('addFaceStock','addAdhesive','addLiner','');
$thirdValue1 = array('Add Face Stock Specs','Add Adhesive Specs','Add Liner Specs','');
for($x = 0; $x<count($third); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$third[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"2\">$thirdTitles[$x]</td>\n";
echo "<td width=50px>\n\n<input class=\"btn\" type=\"".$thirdType[$x]."\" name=\"".$thirdName[$x]."\" value=\"".$thirdValue[$x]."\"></td>\n\n";
echo "<td width=50px>\n<input class=\"btn\" type=\"".$thirdType1[$x]."\" name=\"".$thirdName1[$x]."\" value=\"".$thirdValue1[$x]."\"></td></tr>\n\n";
}
?>
<tr><td width="100px" colspan="2" valign="top"><br><input type="reset" class="btn" value="Reset Summary"></td>
<td width="100px" colspan="2" valign="top"><br><input type="submit" name="submit1" class="btn" value="addSummary"></td></tr>
<?
echo "</table></form>";
include "template.tpl";
}
}//Close list_summary function
// Setup switch - View or Submit
switch($action) {
case "viewFaceStock": fnViewFaceStockSpec(); break;
case "viewAddFaceStock": fnAddFaceStock(); break;
case "viewAdhesive": fnViewAdhesive(); break;
case "addAdhesive": fnAddAdhesive(); break;
case "viewLiner": fnViewLiner(); break;
case "addLiner": fnAddLiner(); break;
case "addFs": fnCreateFs(); break;
case "addFaceStock": viewAddFaceStock(); break;
default: viewFaceStockSummary(); break;
}
?>