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 Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/ 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 Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/#findComment-279162 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 Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/#findComment-279167 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 Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/#findComment-279168 Share on other sites More sharing options...
graham23s Posted June 21, 2007 Author Share Posted June 21, 2007 lol done:) Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/#findComment-279169 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> Link to comment https://forums.phpfreaks.com/topic/56523-solved-blank-submission-code/#findComment-279180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.