First, Merve: Nice to see Chrétien still gets some mention 🙂
Second, the $_POST[] stuff worked.
My next problem has to do with the nested form:
I have a hidden field which is to fire the MySQL insert of the form on postback. However when I submit the second form (nested inside the first to trigger the Country/Territory posting) I cant get them to separate. Its either it will do the Insert, or If I zero out the trigger inside the second form, it messes up the submit of the final information.
Adding code here
<?php
include('../../_includes/functions.php');
$countryid=$_POST[countryid];
$added=false;
$is_admin=true;
if($_POST["dosave"]=="1"){
$sql_insert="INSERT INTO `mi_store_operators` (`id`,`store_operator_name`,`corporate_business_num`,`corporate_name`,`store_name`,`store_street_address`,`store_city`,`store_prov_terr`,`store_phone_num`,`store_fax_num`,`store_email`,`store_category`,`store_sub_category`,`store_size`,`store_shelf_avail`,`store_monthly_charge`,`store_paypal_info`,`store_req_percentage`,`store_sus`,`store_photo_location`,`store_username`,`store_password`)";
$sql_insert.="VALUES (";
$sql_insert.="NULL,'".$_POST["store_operator_name"]."','".$_POST["corporate_business_num"]."','".$_POST["corporate_name"]."','".$_POST["store_name"]."','".$_POST["store_street_address"]."','".$_POST["store_city"]."','".$_POST["store_prov_terr"]."','".$_POST["store_phone_num"]."','".$_POST["store_fax_num"]."','".$_POST["store_email"]."','".$_POST["store_category"]."','".$_POST["store_sub_category"]."','".$_POST["store_size"]."','".$_POST["store_shelf_avail"]."','".$_POST["store_monthly_charge"]."','".$_POST["store_paypal_info"]."','".$_POST["store_req_percentage"]."','".$_POST["store_sus"]."','".$_POST["store_photo_location"]."','".$_POST["store_username"]."','".$_POST["store_password"]."'";
$sql_insert.=");";
$open_db = new DB;
mysql_query($sql_insert);
$newid = mysql_insert_id();
open_db.close;
$added=true;
}
?>
<HTML>
<HEAD>
<script language=javascript src=/_includes/date-picker.js></script>
<script language="javascript">
var tmpBuffer='';
function validation(){
var msg='';
if(document.forms[0].name.value==''){msg+='\n -Name';}
if(msg==''){
return true;
}else{
alert('You forgot to fill the following fields:\n' + msg);
return false;
}
}
</script>
<link href="/_admin/style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
<FORM name="mainform" ACTION="add.php" method="POST"><!-- onSubmit="return validation();">-->
<input type="hidden" name="dosave" value="1">
<TABLE WIDTH="100%" align="center" border="0">
<tr>
<td align="center"><BR><font class="txtPageHdr">Adding a Store</font><BR><BR></td>
</tr>
<tr><td WIDTH="100%" align="center">
<TABLE WIDTH="250" align="center" border="0">
<?if(!$added){?>
<TR>
<TD align="left"><FONT class=txtReg>Store Operator Name </FONT><br>
<input type="text" name="store_operator_name" value="<? echo $_POST[store_operator_name]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Corporate Business Number </FONT><br>
<input type="text" name="corporate_business_num" value="<? echo $_POST[corporate_business_num]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store Corporate Name </FONT><br>
<input type="text" name="corporate_name" value="<? echo $_POST[corporate_name]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Store Name </FONT><br>
<input type="text" name="store_name" value="<? echo $_POST[store_name]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store Street Address </FONT><br>
<input type="text" name="store_street_address" value="<? echo $_POST[store_street_address]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store City </FONT><br>
<input type="text" name="store_city" value="<? echo $_POST[store_city]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store Country </FONT><br>
<form action="add.php" method="post" name="getcountry">
<select name="countryid" onchange="this.form.submit()"><? showcountry($countryid); ?>
</select>
<input type="hidden" name="dosave" value="0">
</form>
<input name="store_country" type="hidden" value="<? echo $countryid; ?>">
</td>
<TD align="left"><FONT class=txtReg>Store Province/State </FONT><br>
<select name="store_prov_terr"><? showprovince($countryid); ?>
</select>
</td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store Phone Number </FONT><br>
<input type="text" name="store_phone_num" value="<? echo $_POST[store_phone_num]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Fax Number </FONT><br>
<input type="text" name="store_fax_num" value="<? echo $_POST[store_fax_num]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store email address </FONT><br>
<input type="text" name="store_email" value="<? echo $_POST[store_email]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Category </FONT><br>
<input type="text" name="store_category" value="<? echo $_POST[store_category]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Store Sub-Category </FONT><br>
<input type="text" name="store_sub_category" value="<? echo $_POST[store_sub_category]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Size (sq. feet) </FONT><br>
<input type="text" name="store_size" value="<? echo $_POST[store_size]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Shelf Space available </FONT><br>
<input type="text" name="store_shelf_avail" value="<? echo $_POST[store_shelf_avail]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Monthly Charge for Shelf Space </FONT><br>
<input type="text" name="store_monthly_charge" value="<? echo $_POST[store_monthly_charge]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Paypal Link Address </FONT><br>
<input type="text" name="store_paypal_info" value="<? echo $_POST[store_paypal_info]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Required percentage on sales </FONT><br>
<input type="text" name="store_req_percentage" value="<? echo $_POST[store_req_percentage]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Shelf Unit Size </FONT><br>
<input type="text" name="store_sus" value="<? echo $_POST[store_sus]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Photograph </FONT><br>
<input type="file" name="store_photo_location" value="<? echo $_POST[store_photo_location]; ?>" size="40"></td>
</TR>
<TR>
<TD align="left"><FONT class=txtReg>Username </FONT><br>
<input type="text" name="store_username" value="<? echo $_POST[store_username]; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Password </FONT><br>
<input type="password" name="store_password" value="<? echo $_POST[store_password]; ?>" size="40"></td>
</TR>
<TR>
<TD align="center" colspan='2'><BR><INPUT TYPE="button" VALUE=" Back " onClick="document.location='index.php';"> <INPUT TYPE="SUBMIT" VALUE=" Add "><BR><BR></TD>
</TR>
<?}else{?>
<TR>
<TD colspan="2" align="center"><FONT class="txtReg"><b>Store added successfully !</b><br><br>What would you like to do ?<br><br></FONT></td>
</TR>
<TR>
<TD colspan="2" align="center"><INPUT TYPE="button" VALUE="Manage Stores" onClick="document.location='index.php';"> <INPUT TYPE="button" VALUE="Add Another Store" onClick="document.location='add.php';"><BR><BR></TD>
</TR>
<?}?>
</TABLE>
</td></tr></table>
</FORM>
</body>
</HTML>