Jump to content

[SOLVED] Blank Submission code


graham23s

Recommended Posts

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

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

 

 

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.