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=mysqli_real_escape_string($dbc, trim($_POST['id']));
$user_name=$_POST['user_name'];
$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']));
$bookname=strip_tags(trim($_POST['bookname']));
$song1=strip_tags(trim($_POST['song1']));
$song2=strip_tags(trim($_POST['song2']));
$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))
{
$dbc=mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME)
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');
mysqli_query($dbc,$query)
or die('Error querying database.');