Image and no image

Image and no image

am 03.05.2009 22:26:52 von Joey Hendricks

------=_NextPart_000_0078_01C9CC03.95FD1850
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,
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=3Dmysqli_real_escape_string($dbc, trim($_POST['id']));
$user_name=3D$_POST['user_name'];
$image=3Dmysqli_real_escape_string($dbc, =
trim($_FILES['image']['name']));
$image_type=3Dmysqli_real_escape_string($dbc, =
trim($_FILES['image']['type']));
$image_size=3Dmysqli_real_escape_string($dbc, =
trim($_FILES['image']['size']));
$bookname=3Dstrip_tags(trim($_POST['bookname']));
$song1=3Dstrip_tags(trim($_POST['song1']));
$song2=3Dstrip_tags(trim($_POST['song2']));
$booklink=3Dmysqli_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 <=3D JGT_MAXFILESIZE))
{
if ($_FILES['image']['error'] == 0)
{
// Move the file to the target upload folder
$target =3D JGT_UPLOADPATH . $image;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target))
{


$dbc=3Dmysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME)
or die('Error connecting to the server');
$query=3D"INSERT INTO tabs (user_name, image, bookname, song1, song2, =
booklink) VALUES ('$user_name', '$image', '$bookname', '$song1', =
'$song2', '$booklink')";
mysqli_query($dbc,$query)
or die('Error querying database.');
------=_NextPart_000_0078_01C9CC03.95FD1850--