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
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

 

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.