Here is my thing. I need to submit Stores into the database administration. It has to on the fly pull dynamic data for Country/Province and for Category/Sub-Category.
It works so far, except the only way I can get it to do the complete part is to have in the if statment, that if the "username" is not empty to do the database insert.
How I want it to function is: Fill out the form, Select the country, get the Province/State, select the Province state, keep filling out the form, select the category, get the appropriate sub-categories, select a sub category, finish filling out the form, hit submit, record gets added to the database.
<?php
include('../../_includes/functions.php');
$countryid=$_POST[countryid];
$added=false;
$is_admin=true;
if(($_POST["dosave"]=="1") and ($_POST[store_username]!="")){
$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>
<link href="/_admin/style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
<FORM 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>
<select name="countryid" onchange="this.form.submit();"><? showcountry($countryid); ?>
</select>
<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 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>Store Category </FONT><br>
<select name="category" onchange="this.form.submit();"><? showcategory($category); ?>
</select>
<input type="hidden" name="store_category" value="<? echo $category; ?>" size="40"></td>
<TD align="left"><FONT class=txtReg>Store Sub-Category </FONT><br>
<select name="store_sub_category"><? showsubcategory($category,$_POST[store_sub_category]); ?>
</select></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>