jrm Posted October 23, 2008 Share Posted October 23, 2008 I am having a small problem with one of my "isset()" statements. Under "case 2", the third "if"statement, it will not goto the "else" part of the function. <?php include "InventoryFunctions.php"; include_once "StaffNameFunc.php"; include_once "MemberFunctions.php"; /* require_once "./login/settings.php"; include "MemberFunctions.php"; include "DailyLogFunctions.php"; checkLogin('1 2'); */ $error = Null; /* `Inventory`.`Request` `RequestID` int(10) NOT NULL auto_increment, `StaffID` int(10) default NULL, `DTGRequest` datetime default NULL, `DTGCreated` timestamp NOT NULL default CURRENT_TIMESTAMP, `User` varchar(50) default NULL, `Computer` varchar(50) default NULL, */ $StaffList = StaffList(); if(isset($_POST["Form"])) { $tForm = (int)$_POST["Form"]; $error = Null; switch($tForm) { case 1: if(isset($_POST["StaffName"]) and isset($_POST["Year"]) and isset($_POST["Month"]) and isset($_POST["Day"])) { if(strlen($_POST["Year"])>4) $error = $error . " : " . " Check Year Format, incorrect number of numbers. "; if(strlen($_POST["Month"])>2) $error = $error . " : " . " Check Month Format, incorrect number of numbers. "; if(strlen($_POST["Day"])>2) $error = $error . " : " . " Check Day Format, incorrect number of numbers. "; //$Time = strtotime($_POST["Time"]); $DTG = mktime(0,0,0,$_POST["Month"],$_POST["Day"],$_POST["Year"]); if(isset($error)) { $Form = 1; } else { $user = 3; $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); $Computer = $hostname . ":" . $_SERVER["REMOTE_ADDR"]; $ReqstID = startRequest($_POST["StaffName"],$DTG,$user,$Computer); $Form = 2; $Cats = getCategories(); } } else { $Form = 1; } break; case 2: if(isset($_POST["ReqstID"])) { $Cats = getCategories(); for($i = 0; $i <= count($Cats) - 1; $i++) { if(count($Cats[$i]["Products"])==1) { $i++; break; } else { for($j = 0; $j <= count($Cats[$i]["Products"]) - 1; $j++) { if(isset($_POST["checkbox_" . $Cats[$i]["Products"][$j]["ProdID"] ])) { if(isset($_POST["Qty_" . $Cats[$i]["Products"][$j]["Name"] ])) { $Request[] = array("ID" => $Cats[$i]["Products"][$j]["ProdID"], "Name" => $Cats[$i]["Products"][$j]["Name"], "Qty" => $_POST["Qty_" . $Cats[$i]["Products"][$j]["Name"]]); $Form = 2; } else { $error = $error . " : " . "Missing Quantity for :" . $Cats[$i]["Products"][$j]["Name"]; $Form = 2; } } else { $Form = 2; } } } } } else { $Form = 1; } break; } } else { $Form = 1; } ?> <html> <head> <link rel=stylesheet type="text/css" href="./themes/theme.css"> <title>Hidalgo County Juvenile Boot Camp Intranet Access</title> </head> <body> <?php if(isset($error)){ echo "\n<p>" . $error . "</p>\n";} ?> <form class="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="Form" value="<?php echo $Form; ?>" > <input type="hidden" name="ReqstID" value="<?php echo isset($ReqstID)?$ReqstID:Null;?>"> <?php switch($Form) { case 1: ?> <table width = 40% align = center> <tr> <th colspan = 3> Date of Request </th> </tr> <tr> <td width = 33%> <label for="Year">Year</label> <input type="text" name="Year" size=4 value="<?php echo (isset($_POST["Year"])?$_POST["Year"]: date("Y"));?>" > <br>#### </td> <td width = 33%> <label for="Month">Month</label> <input type="text" name="Month" size=2 value="<?php echo (isset($_POST["Month"])?$_POST["Month"]: date("m"));?>" > <br>## </td> <td width = 33%> <label for="Day">Day</label> <input type="text" name="Day" size=2 value="<?php echo (isset($_POST["Day"])?$_POST["Day"]: date("d"));?>" > <br>## </td> </tr> </table> <select name="StaffName" value="<?php echo (isset($_POST["StaffName"])? $_POST["StaffName"] : "") ?>" > <?php for($i=0; $i<=count($StaffList)-1; $i++) { ?> <option value="<?php echo $StaffList[$i]["StaffID"]; ?>"<?php if(isset($_POST["StaffName"])) echo (($_POST["StaffName"]==$StaffList[$i]["StaffID"])? "selected" : ""); ?> > <?php echo $StaffList[$i]["StaffName"]; ?></option> <? } ?> </select> <br> <input type="submit" name="submit" value="submit"> <? break; case 2: for($i = 0; $i <= count($Cats) - 1; $i++) { if(count($Cats[$i]["Products"])==1) { ?> <table width = 100% align = center> <tr> <th colspan=1><?php echo $Cats[$i]["Category"]; ?></td> </tr> <tr> <td width = 100% align = center><?php echo "\n". $Cats[$i]["Products"];?></td> </td> </table> <br><hr><br> <? } else { ?> <table width = 100% align = center> <tr> <th colspan = 5><?php echo $Cats[$i]["Category"]; ?></th> </tr> <tr> <td width = 10%><br></td> <td width = 15%>Product Name</td> <td width = 10%>Size of Product</td> <td width = 10%>Shipment Size</td> <td width = 15%>Quantity of Shipment Size</td> </tr> <? for($j = 0; $j <= count($Cats[$i]["Products"]) - 1; $j++) { ?> <tr> <td width = 5%> <input type="checkbox" name="checkbox_<?php echo $Cats[$i]['Products'][$j]['ProdID']; ?>" > </td> <td width = 15%><?php echo $Cats[$i]["Products"][$j]["Name"]; ?></td> <td width = 10%><?php echo $Cats[$i]["Products"][$j]["Size"];?></td> <td width = 10%><?php echo $Cats[$i]["Products"][$j]["ShipSize"]?></td> <td width = 15%><input type="text" name="Qty_<?php echo $Cats[$i]["Products"][$j]["Name"]; ?> " size=4 value="" ></td> </tr> <? } ?> </table> <br><hr><br> <? } } ?> <input type="submit" name="submit" value="submit"> <? if(isset($Request)) print_r($Request); break; } ?> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/129796-_post-help/ Share on other sites More sharing options...
jrm Posted October 23, 2008 Author Share Posted October 23, 2008 I figured it out, needed to change the "break;" to a "continue;" Quote Link to comment https://forums.phpfreaks.com/topic/129796-_post-help/#findComment-672879 Share on other sites More sharing options...
jrm Posted October 24, 2008 Author Share Posted October 24, 2008 Probably need to move this post to the php section. But I still can not get it to check the $_POST["QTY_"...... correctly. I did change the second if else statement so that it is checking for an array or not. If if(isset($_POST["Qty_" . $Cats[]["Products"][]["Name"])) is false then return an error for that Product, and go to the next loop of the for($i=0;$i<=count($Cats[]["Products"])- 1; $i++). The output that I am getting is that $Request[] is being set and no quantity error is being reported, but an error of "Nothing Requested." if(isset($_POST["ReqstID"])) { $Cats = getCategories(); for($i = 0; $i <= count($Cats) - 1; $i++) { if(is_array($Cats[$i]["Products"])) { for($j = 0; $j <= count($Cats[$i]["Products"]) - 1; $j++) { if(isset($_POST["checkbox_" . $Cats[$i]["Products"][$j]["ProdID"] ])) { if(isset($_POST["Qty_" . $Cats[$i]["Products"][$j]["Name"] ])) { $Request[] = array("ID" => $Cats[$i]["Products"][$j]["ProdID"], "Name" => $Cats[$i]["Products"][$j]["Name"], "Qty" => $_POST["Qty_" . $Cats[$i]["Products"][$j]["Name"]]); $Form = 2; } else { $error = $error . " : " . "Missing Quantity for :" . $Cats[$i]["Products"][$j]["Name"]; $Form = 2; } } else { $Nothing = "Nothing"; } } if(isset($Nothing)) { $error = $error . " : " . "Nothing Requested."; $Form = 2; } } else { continue; } } } else { $Form = 1; } Quote Link to comment https://forums.phpfreaks.com/topic/129796-_post-help/#findComment-673675 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.