I have this set up to upload an image and if any of the fields are empty you 
get a "All fields required". Now I can't figure out how to post the upload with 
or without an image. This is the code I have so far: I want to thank everybody 
so very much for all of your help!!!!!

if (isset($_POST['submit']))
//Grab user data
$id=mysqli_real_escape_string($dbc, trim($_POST['id']));
$image=mysqli_real_escape_string($dbc, trim($_FILES['image']['name']));
$image_type=mysqli_real_escape_string($dbc, trim($_FILES['image']['type']));
$image_size=mysqli_real_escape_string($dbc, trim($_FILES['image']['size']));
$booklink=mysqli_real_escape_string($dbc, trim($_POST['booklink']));

if (!empty($user_name) && !empty($image) && !empty($bookname) && !empty($song1) 
&& !empty($song2) && !empty($booklink))
      if ((($image_type == 'image/gif') || ($image_type == 'image/jpeg') || 
($image_type == 'image/pjpeg'))
        && ($image_size > 0) && ($image_size <= JGT_MAXFILESIZE))
        if ($_FILES['image']['error'] == 0)
          // Move the file to the target upload folder
          $target = JGT_UPLOADPATH . $image;
          if (move_uploaded_file($_FILES['image']['tmp_name'], $target))

or die('Error connecting to the server');
$query="INSERT INTO tabs (user_name, image, bookname, song1, song2, booklink) 
VALUES ('$user_name', '$image', '$bookname', '$song1', '$song2', '$booklink')";
or die('Error querying database.');

Reply via email to