Q:

How to stop sending $_FILES['name'] if nobody provides thefile?

I Have a multipart/form-data form but I not require from users to send me the picture. I am changing the name of the file to random number and the put the path to MySQL. Whenever somebody doesn't put the file, in my database a new recor is beeing created without an extension(obviesly). How to stop this from happening?
Sorry for my english.
Here is a a part from the code:
 case 'Sleep Aid': {
      ?>
    <section class="summarySection">
      <div class="summaryHeadingDIV">
        <h1 class="summaryH1">Please check the details below</h1>
      </div>
      <article class="summaryPage">
        <p class="boldSummaryDescr">Brand:</p><p class="paraSummary"><?php echo $brand; ?></p><br>
        <p class="boldSummaryDescr">Model:</p><p class="paraSummary"><?php echo $model; ?></p><br>
        <p class="boldSummaryDescr">Colour:</p><p class="paraSummary"><?php echo $colour; ?></p><br>
        <p class="boldSummaryDescr">Material:</p><p class="paraSummary"><?php echo $material; ?></p><br>
        <p class="boldSummaryDescr">Suitable Age:</p><p class="paraSummary"><?php echo $suitable; ?></p><br>
        <p class="boldSummaryDescr">Purchase date:</p><p class="paraSummary"><?php echo $month . '/' . $year; ?></p><br>
        <p class="boldSummaryDescr">Condition:</p><p class="paraSummary"><?php echo $condition; ?></p><br>
        <p class="boldSummaryDescr">Dimesions:</p><p class="paraSummary"><?php echo $width . ' cm <span class="smallcaps">x</span> ' . $height . ' cm <span class="smallcaps">x</span> ' . $depth . ' cm'; ?></p><br>
        <p class="boldSummaryDescr">Weight:</p><p class="paraSummary"><?php echo $weight . ' kg'; ?></p>
      </article>
      <div class="imageg_container">
        <figure class="img_figure_show">
          <?php 
          if(empty($picture))
          {
            ?>              
            <img src="/_images/no-picture.png" alt="no picture added">
            <?php
          }
          else
          {

            $random_id = rand_img_id();
            add_file(db_user_connect(), $email, $random_id);
            $arry = show_picture(db_user_connect(), $email, $random_id); 
            print "<img src=".$arry["sciezka"]." alt='product picture'>";
          }
          ?>
        </figure>
      </div>
      <div class="clear-left"></div>
      <div class="summaryButtonContainer">
        <a href="javascript:goBack();" class="summaryLinks" title="Go Back">Edit details</a>
        <a href="/_pages/transaction/quotation.php?location=sleepaid&brand=<?php echo urlencode($brand);?>&model=<?php echo urlencode($model)?>&month=<?php echo urlencode($month);?>&year=<?php echo urlencode($year);?>&condition=<?php echo urlencode($condition);?>" class="summaryLinks">Proced to Quote</a>
      </div>
    </section>
    <?php
    break;
  }

A:

You need to check the $_FILES['error'] value:
if ($_FILES['name']['error'] === UPLOAD_ERR_OK) ...

The manual lists all possible values, which you could use to display different messages/do different things: https://secure.php.net/manual/en/features.file-upload.errors.php

