rvinikof Posted July 23, 2007 Share Posted July 23, 2007 Using this code: if ($Numofbooks != "") { for ($i = 0; $i < $Numofbooks; $i++) { $Author = $_POST["bookauthor"]; $Title = $_POST["booktitle"]; $Edition = $_POST["edition"]; $ISBN = $_POST["isbn"]; $ReqorOpt = $_POST["reqoropt"]; if (isset($Author[$i])) { echo "<center>"; echo "Please enter an author for every book."; echo '<br/><a><input type="button" value = "Back." onclick = "history.go(-1)"></a>'; echo "</center>"; exit(); } if ($Title[$i] == "") { echo "<center>"; echo "Please enter a title for every book."; echo '<br/><a><input type="button" value = "Back." onclick = "history.go(-1)"></a>'; echo "</center>"; exit(); } if (($ISBN[$i] == "") || (strlen($ISBN[$i]) != 13)) { echo "<center>"; echo "Please enter a 13-digit ISBN for every book."; echo '<br/><a><input type="button" value = "Back." onclick = "history.go(-1)"></a>'; echo "</center>"; exit(); } $sqlinsertlogin = "INSERT INTO bookrequest (requestID, author, title, edition, isbn, loginID, reqoropt, courseID) VALUES ('', '".$Author[$i]."', '".$Title[$i]."', '".$Edition[$i]."', '".$ISBN[$i]."', '".$loginid[0]."', '".$ReqorOpt[$i]."', '".$crnforclass[0]."')"; $insertlogin = mysql_query($sqlinsertlogin); if (!$insertlogin) { $insertloginerr = mysql_error(); echo $insertloginerr; exit(); } } } I'm trying to check to make sure that for every book, every author, title, and isbn is not empty. However, it seems like it only checks the first book. If the first book has an author, but the second doesn't, then it checks title and keeps going. The only time the error pops up is if the first author, title, isbn is empty. How do I make sure that it checks for every author? Quote Link to comment 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.