Im trying to get this code to work. This is a checkout im working on for my site, the user selects a package and types in how much of those packages they want. If they type '1' it shows just the text boxes for 1. But if they choose '5' it shows those text boxes 5 times. IE: I choose '3' for the quantity. It will show: #1 Site Name: Site Url: Etc: Etc: #2 Site Name: Site Url: Etc: Etc: #3 Site Name: Site Url: Etc: Etc: but the code i have will check #1, if all fields are present, it accepts it. Then it checks #2, if a field is present, it rejects it. Then #3 if all fields are present, it accepts it. I want it to reject ALL (ie #1 and #2 have all the fields present, but #3 is missing a field, then it rejects them all) <? $qty = $_POST['qnty']; $total = $_POST['cost']; $name = $_POST['name']; $ppemail = $_POST['email']; $pkg = $_POST['package']; while($n < $qty){ $sn= $n + 1; $sname = $_POST['sname'.$sn.'']; $surl = $_POST['surl'.$sn.'']; $stags = $_POST['stags'.$sn.'']; $scat = $_POST['scategory'.$sn.'']; $sdesc = $_POST['sdescription'.$sn.'']; if(($name == "")||($ppemail == "")||($sname == "")||($surl == "")||($stags == "")||($scat == "")||($sdesc == "")) { $n++; echo'You forgot something, go back!'; }else{ $n++; echo'Accepted'; } } ?> PHP: Edit: can someone move this to the php section?
Dont do PHP but the logic for doing it is the same across any language Set a variable (eg ErrorTxT) before the while loop, go through the loop each time and if your if statement comes out as True then change the ErrorTxT to true, if the if statement comes back as false then leave the errortxt variable in its current state. After the loop do the You forgot/ Accepted element based on the value of ErrorTxT