graham23s Posted June 21, 2007 Share Posted June 21, 2007 Hi Guys, on my site i allow multiple files to be uploaded at once , but was wanting to put in some code so that if a black submission (no photos selected) was submitted the code would spit an error and exit i have this: ## empty submission ################################################################ if(empty($headshot1) || empty($headshot2) || empty($headshot3) || empty($headshot4) || empty($headshot5)) { echo 'EMPTY'; include("includes/footer.php"); exit; } but this needs you to upoad all 5 at the 1 time, and some users might only want to upload 1,2 or 3 not the whole 5 this is easy enough with post data but this has stumped me. thanks guys Graham Quote Link to comment Share on other sites More sharing options...
chrisuk Posted June 21, 2007 Share Posted June 21, 2007 so do you only want an empty message if all 5 are empty? If this is the case then use AND (&&) instead of OR (||) Currently your code will spit an error if any of the fields are empty because of the OR. Using the && will mean that if all 5 are empty you will get the error but not under any other circumstances Quote Link to comment Share on other sites More sharing options...
graham23s Posted June 21, 2007 Author Share Posted June 21, 2007 cheers chris thats exactly what i was after:) Graham Quote Link to comment Share on other sites More sharing options...
chrisuk Posted June 21, 2007 Share Posted June 21, 2007 Not a problem. If this has solved it go ahead and mark the topic as solved or you will get some of the rulebies on your case Quote Link to comment Share on other sites More sharing options...
graham23s Posted June 21, 2007 Author Share Posted June 21, 2007 lol done:) Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 21, 2007 Share Posted June 21, 2007 done this for fun to cheek form input. <?php if(isset($_POST['submit'])){ foreach($images as $a => $x){ if(empty($x)){ echo "<center> <br>Sorry empty field $a <br> </center>"; }else{ echo "<center> <br> field $a sent: (Text Sent: <font color='red'>$x</font>) <br> </center>"; } } } ?> <center> <form method="POST" action = " <?php echo $_SERVER['PHP_SELF']?> " > <?php for($i=0; $i<4; $i++){ echo"<br>Field number: $i<br><input type='text' name='images[]'>"; } ?> <p></p> <input type="submit" name="submit" value="post me!"> </form> </center> 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.