Notice: Undefined index:

Hi I keep returning this error:

Notice: Undefined index: file_location in /home/www/forum/post.php on line 85

Here is the code I have on line 85:

if (is_uploaded_file($_FILES['file_location']['tmp_name'])) {

I am adding a photo adding facility to a post form, code below for the post page:

if (isset($_GET['action']) && ($_GET['action'] == 'new_topic' || $_GET['action'] == 'new_poll')) {
	if (!isset($_POST['submit'])) {
		$body->set('forum_id', $forum_id);
		$tpl->set('body', $body->fetch('post_' . ($_GET['action'] == 'new_topic' ? 'topic' : 'poll') . '_new.tpl.php'));
	} else {
		$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$first_name			= isset($_POST['first_name	']) ? check_input($_POST['first_name	']) : '';
		$last_name			= isset($_POST['last_name']) ? check_input($_POST['last_name']) : '';
		$phone				= isset($_POST['phone']) ? check_input($_POST['phone']) : '';
		$email				= isset($_POST['email']) ? check_input($_POST['email']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$poll				= isset($_POST['poll']) ? str_replace(array('|', '##'), '', check_input($_POST['poll'])) : '';
		$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

		if ($subject == '' || $message == '' || $ad_type == '' || $pet_type == '' || $breed == '' || $gender == '' || $price == '') {
			error('You did not fill in all the required fields. Please try again!', '/forum/post.htm?action=new_topic&forum_id=1');
		}

		$poll_answers = '';

		if ($poll != '') {
			foreach (explode("\\\
", $poll) as $answer) {
				$poll_answers .= ($poll_answers != '' ? '##' : '') . str_replace('\\r', '', $answer) . '|0';
			}
		}
		
		// Upload File

		if (is_uploaded_file($_FILES['file_location']['tmp_name'])) {
			$file_name = $upload->get_file_name($image_name, strtolower(strrchr($_FILES['file_location']['name'], '.')));

		if ($upload->upload_file($file_name, $_FILES['file_location']['tmp_name'], array('.gif', '.jpg', '.jpeg', '.png'), $config['gallery_image_file_size'], $config['gallery_image_width'], $config['gallery_image_height'])) {
			$upload->upload_resized_image('medium/', $file_name, $config['gallery_image_medium_width'], $config['gallery_image_medium_height']);
			$upload->upload_resized_image('thumbnails/', $file_name, $config['gallery_thumbnail_width'], $config['gallery_thumbnail_height']);
		} else {
			error('Invalid image entered!');
		}
	} else {
		error('You must select an image!');
	}

	$db->query("INSERT INTO " . $config['db']['prefix'] . "gallery_images (image_url, date_created, date_edited) VALUES ('$file_name', " . time() . ", " . time() . ")");

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_topics (forum_id, user_id, subject, poll, topped, date_created, num_replies, num_views, last_post_date, last_poster_id) VALUES ($forum_id, $user_data[user_id], '$subject', '$poll_answers', $topped, " . time() . ", 0, 0, " . time() . ", $user_data[user_id])");
		$topic_id = $db->insert_id();

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_posts (topic_id, user_id, ad_type, pet_type, breed, gender, colours, dob, available, price, message, first_name, last_name, phone, email, address_line1, address_line2, city, county, country_id, postcode, date_created, is_first) VALUES ($topic_id, $user_data[user_id], '$ad_type', '$pet_type', '$breed', '$gender', '$colours', '$dob', '$available', '$price', '$message', '$first_name', '$last_name', '$phone', '$email', " . time() . ", 1)");
		$post_id = $db->insert_id();

		$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET last_post_id = $post_id WHERE topic_id = $topic_id");
		$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts + 1 WHERE user_id = $user_data[user_id]");

		update_forum($forum_id);
		
		if ($subscribe == 'yes') {
			$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($user_data[user_id], $topic_id)");
		}

		output('Your topic has been successfully submitted! Please wait while we redirect you to your post.');
		redirect('/forum/' . get_url_forum($forum['forum_id'], $forum['forum_name'], $topic_id, $subject), 2);
	}
}

I have the ‘file_location’ working using avatar for regisration, but can’t seem to get this one working.

If anyone could help or have any guidance would be most grateful.

Thanks,

Paul

The error is telling you that you are trying to reference a key in an array which does not exist.

So, do a var_dump( $_FILES ) ; and then you will see what is actually in there that you can reference.

I did the var_dump and this is what the error returned:

array(0) { }
Notice: Undefined index: file_location in /home/www/forum/post.php


<?php
echo '<pre>',print_r($_FILES),'</pre>';
exit;

if (is_uploaded_file($_FILES['file_location']['tmp_name'])) {
?>

Please post what that outputs.

The first step to debugging this is to see what is in the files array. Most likely the key your referencing is not the correct key. However, to actually see if that is the case the $_FILES array needs to examined.

All that returned was this:

Array
(
)
1

Not quite sure what that is, and never seen it before.

In that case, nothing is being uploaded.

Are you actually uploading anything to the page at the time?

Yeah, I am using a template system… on the HTML page this is the upload form which I use to select the image (post_topic_new.tpl.php):

<input type=“file” name=“file_location” />


And then within the post.php file (which has all the main code) is where the

if (is_uploaded_file($_FILES['file_location']['tmp_name'])) {

is placed.

I do exactly the same with the avatar so users can add an image and it works. - it all links to a upload.class.php file.

Here is the code for the ‘post.php’ - everything seems to be just fine, but keep returning the index error :frowning:

<?php

define('CACHECONTROL', 'private');
define('ROOT_PATH', './../');
require ROOT_PATH . 'includes/common.inc.php';

include_once ROOT_PATH . 'includes/upload.class.php';
$upload = new upload(ROOT_PATH . 'images/gallery/');

$tpl	= new template(ROOT_PATH . $config['template_path']);
$body	= new template(ROOT_PATH . $config['template_path'] . 'forum/');

$forum_id	= isset($_REQUEST['forum_id']) && is_numeric($_REQUEST['forum_id']) ? (int) $_REQUEST['forum_id'] : 0;
$topic_id	= isset($_REQUEST['topic_id']) && is_numeric($_REQUEST['topic_id']) ? (int) $_REQUEST['topic_id'] : 0;
$post_id	= isset($_REQUEST['post_id']) && is_numeric($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;

if (isset($_GET['action']) && ($_GET['action'] == 'new_topic' || $_GET['action'] == 'new_poll')) {
	$result = $db->query("SELECT forum_id, forum_name FROM " . $config['db']['prefix'] . "forum_forums WHERE forum_id = $forum_id");
	$forum = $db->fetch_array($result);

	$tpl->set('title', $forum['forum_name'] . ' - New ' . ($_GET['action'] == 'new_topic' ? 'Topic' : 'Poll') . ' - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($forum['forum_id'], $forum['forum_name']) . '">' . $forum['forum_name'] . '</a> &raquo; New ' . ($_GET['action'] == 'new_topic' ? 'Topic' : 'Poll'));
} elseif (isset($_GET['action']) && $_GET['action'] == 'new_reply') {
	$result = $db->query("SELECT t.topic_id, t.forum_id, t.subject, f.forum_name FROM " . $config['db']['prefix'] . "forum_topics t INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id WHERE t.topic_id = $topic_id");
	$topic = $db->fetch_array($result);

	$tpl->set('title', $topic['subject'] . ' - Reply - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name']) . '">' . $topic['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject']) . '">' . $topic['subject'] . '</a> &raquo; Reply');
} elseif (isset($_GET['action']) && $_GET['action'] == 'move_topic') {
	$result = $db->query("SELECT t.topic_id, t.forum_id, t.subject, f.forum_name FROM " . $config['db']['prefix'] . "forum_topics t INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id WHERE t.topic_id = $topic_id");
	$topic = $db->fetch_array($result);

	$tpl->set('title', $topic['subject'] . ' - Move - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name']) . '">' . $topic['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject']) . '">' . $topic['subject'] . '</a> &raquo; Move');
} elseif (isset($_GET['action']) && ($_GET['action'] == 'mark_read')) {
	$tpl->set('title', 'Mark topics as read - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; Mark topics as read');
} else {
	$result = $db->query("SELECT p.post_id, p.user_id, p.ad_type, p.pet_type, p.breed, p.gender, p.colours, p.dob, p.available, p.price, p.message, p.is_first, p.date_created, t.topic_id, t.subject, t.topped, f.forum_id, f.forum_name, IF(s.topic_id IS NOT NULL, 1, 0) AS subscribed FROM " . $config['db']['prefix'] . "forum_posts p INNER JOIN " . $config['db']['prefix'] . "forum_topics t ON p.topic_id = t.topic_id INNER JOIN " . $config['db']['prefix'] . "forum_forums f ON t.forum_id = f.forum_id LEFT OUTER JOIN " . $config['db']['prefix'] . "forum_subscriptions s ON t.topic_id = s.topic_id AND s.user_id = $user_data[user_id] WHERE p.post_id = $post_id");
	$post = $db->fetch_array($result);

	$tpl->set('title', $post['subject'] . ' - Edit Post - ' . $config['site_name']);
	$tpl->set('navigation', '<a href="/">Home</a> &raquo; <a href="/forum/">Forum</a> &raquo; <a href="/forum/' . get_url_forum($post['forum_id'], $post['forum_name']) . '">' . $post['forum_name'] . '</a> &raquo; <a href="/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject']) . '">' . $post['subject'] . '</a> &raquo; Edit Post');
}

if ($user_data['group_id'] == GROUPS_GUEST) {
	error('You must be registered to be able to post! Click <a href="/myaccount/register.htm">here</a> to register. Click <a href="/myaccount/login.htm">here</a> to log in.');
}

// New Topic/Poll

if (isset($_GET['action']) && ($_GET['action'] == 'new_topic' || $_GET['action'] == 'new_poll')) {
	if (!isset($_POST['submit'])) {
		$body->set('forum_id', $forum_id);
		$tpl->set('body', $body->fetch('post_' . ($_GET['action'] == 'new_topic' ? 'topic' : 'poll') . '_new.tpl.php'));
	} else {
		$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$first_name			= isset($_POST['first_name	']) ? check_input($_POST['first_name	']) : '';
		$last_name			= isset($_POST['last_name']) ? check_input($_POST['last_name']) : '';
		$phone				= isset($_POST['phone']) ? check_input($_POST['phone']) : '';
		$email				= isset($_POST['email']) ? check_input($_POST['email']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$poll				= isset($_POST['poll']) ? str_replace(array('|', '##'), '', check_input($_POST['poll'])) : '';
		$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

		if ($subject == '' || $message == '' || $ad_type == '' || $pet_type == '' || $breed == '' || $gender == '' || $price == '') {
			error('You did not fill in all the required fields. Please try again!', '/forum/post.htm?action=new_topic&forum_id=1');
		}

		$poll_answers = '';

		if ($poll != '') {
			foreach (explode("\\\
", $poll) as $answer) {
				$poll_answers .= ($poll_answers != '' ? '##' : '') . str_replace('\\r', '', $answer) . '|0';
			}
		}
		
		// Upload File
		
		echo '<pre>',print_r($_FILES),'</pre>';
		exit;

		if (is_uploaded_file($_FILES['file_location']['tmp_name'])) {
			$file_name = $upload->get_file_name($image_name, strtolower(strrchr($_FILES['file_location']['name'], '.')));

		if ($upload->upload_file($file_name, $_FILES['file_location']['tmp_name'], array('.gif', '.jpg', '.jpeg', '.png'), $config['gallery_image_file_size'], $config['gallery_image_width'], $config['gallery_image_height'])) {
			$upload->upload_resized_image('medium/', $file_name, $config['gallery_image_medium_width'], $config['gallery_image_medium_height']);
			$upload->upload_resized_image('thumbnails/', $file_name, $config['gallery_thumbnail_width'], $config['gallery_thumbnail_height']);
		} else {
			error('Invalid image entered!');
		}
	} else {
		error('You must select an image!');
	}

	$db->query("INSERT INTO " . $config['db']['prefix'] . "gallery_images (image_url, date_created, date_edited) VALUES ('$file_name', " . time() . ", " . time() . ")");

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_topics (forum_id, user_id, subject, poll, topped, date_created, num_replies, num_views, last_post_date, last_poster_id) VALUES ($forum_id, $user_data[user_id], '$subject', '$poll_answers', $topped, " . time() . ", 0, 0, " . time() . ", $user_data[user_id])");
		$topic_id = $db->insert_id();

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_posts (topic_id, user_id, ad_type, pet_type, breed, gender, colours, dob, available, price, message, first_name, last_name, phone, email, address_line1, address_line2, city, county, country_id, postcode, date_created, is_first) VALUES ($topic_id, $user_data[user_id], '$ad_type', '$pet_type', '$breed', '$gender', '$colours', '$dob', '$available', '$price', '$message', '$first_name', '$last_name', '$phone', '$email', " . time() . ", 1)");
		$post_id = $db->insert_id();

		$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET last_post_id = $post_id WHERE topic_id = $topic_id");
		$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts + 1 WHERE user_id = $user_data[user_id]");

		update_forum($forum_id);
		
		if ($subscribe == 'yes') {
			$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($user_data[user_id], $topic_id)");
		}

		output('Your topic has been successfully submitted! Please wait while we redirect you to your post.');
		redirect('/forum/' . get_url_forum($forum['forum_id'], $forum['forum_name'], $topic_id, $subject), 2);
	}
}

// New Reply

if (isset($_GET['action']) && $_GET['action'] == 'new_reply') {
	if (!isset($_POST['submit'])) {
		if ($post_id != 0) {
			$result = $GLOBALS['db']->query("SELECT message FROM " . $GLOBALS['config']['db']['prefix'] . "forum_posts WHERE post_id = $post_id");
			$body->set('message', $db->result($result, 0));
		}

		$body->set('forum_id', $forum_id);
		$body->set('topic_id', $topic_id);
		$tpl->set('body', $body->fetch('post_reply_new.tpl.php'));
	} else {
		$message	= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe	= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';

		if ($message == '') {
			error('Your message did not contain any content!');
		}

		$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_posts (topic_id, user_id, message, date_created, is_first) VALUES ($topic_id, $user_data[user_id], '$message', " . time() . ", 0)");
		$post_id = $db->insert_id();

		$result = $db->query("SELECT COUNT(post_id) FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $topic_id");
		$num_replies = $db->result($result, 0) - 1;

		$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET num_replies = $num_replies, last_post_date = " . time() . ", last_post_id = $post_id, last_poster_id = $user_data[user_id] WHERE topic_id = $topic_id");
		$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts + 1 WHERE user_id = $user_data[user_id]");

		update_forum($forum_id);

		// Send subscription emails

		$result = $GLOBALS['db']->query("SELECT u.email FROM " . $GLOBALS['config']['db']['prefix'] . "forum_subscriptions s LEFT OUTER JOIN " . $GLOBALS['config']['db']['prefix'] . "users u ON s.user_id = u.user_id WHERE s.topic_id = $topic_id AND s.user_id != $user_data[user_id]");

		while ($user = $GLOBALS['db']->fetch_array($result)) {
			mail($user['email'], 'Reply to ' . $topic['subject'], 'A reply has been made to the post "' . $topic['subject'] . '" on the ' . $config['site_name'] . ' Forum. Click the link below to view the post.' . "\\r\
\\r\
" . $config['site_url'] . 'forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject'],  $post_id), 'From: ' . $config['admin_email']);
		}

		if ($subscribe == 'yes') {
			$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($user_data[user_id], $topic_id)");
		}

		output('Your post has been successfully submitted! Please wait while we redirect you to your post.');
		redirect('/forum/' . get_url_forum($topic['forum_id'], $topic['forum_name'], $topic['topic_id'], $topic['subject'],  $post_id), 2);
	}
}

// Edit Post

if (isset($_GET['action']) && $_GET['action'] == 'edit_post') {
	if ($post['user_id'] != $user_data['user_id'] && $user_data['group_id'] != GROUPS_ADMIN && $user_data['group_id'] != GROUPS_MOD) {
		error('You do not have permission to edit this post!');
	}

	if (!isset($_POST['submit'])) {
		$body->set('post', $post);
		$tpl->set('body', $body->fetch('post_edit.tpl.php'));
	} else {
		$ad_type			= isset($_POST['ad_type']) ? check_input($_POST['ad_type']) : '';
		$pet_type			= isset($_POST['pet_type']) ? check_input($_POST['pet_type']) : '';
		$breed				= isset($_POST['breed']) ? check_input($_POST['breed']) : '';
		$gender				= isset($_POST['gender']) ? check_input($_POST['gender']) : '';
		$colours			= isset($_POST['colours']) ? check_input($_POST['colours']) : '';
		$dob_day			= isset($_POST['dob_day']) && is_numeric($_POST['dob_day']) && $_POST['dob_day'] > 0 && $_POST['dob_day'] <= 31 ? $_POST['dob_day'] : '';
		$dob_month			= isset($_POST['dob_month']) && is_numeric($_POST['dob_month']) && $_POST['dob_month'] > 0 && $_POST['dob_month'] <= 12 ? $_POST['dob_month'] : '';
		$dob_year			= isset($_POST['dob_year']) && is_numeric($_POST['dob_year']) ? $_POST['dob_year'] : '';
		$dob				= $dob_day . '|' . $dob_month . '|' . $dob_year;
		$available_day		= isset($_POST['available_day']) && is_numeric($_POST['available_day']) && $_POST['available_day'] > 0 && $_POST['available_day'] <= 31 ? $_POST['available_day'] : '';
		$available_month	= isset($_POST['available_month']) && is_numeric($_POST['available_month']) && $_POST['available_month'] > 0 && $_POST['available_month'] <= 12 ? $_POST['available_month'] : '';
		$available_year		= isset($_POST['available_year']) && is_numeric($_POST['available_year']) ? $_POST['available_year'] : '';
		$available			= $available_day . '|' . $available_month . '|' . $available_year;
		$price				= isset($_POST['price']) ? check_input($_POST['price']) : '';
		$message			= isset($_POST['message']) ? check_input($_POST['message']) : '';
		$subscribe			= isset($_POST['subscribe']) && $_POST['subscribe'] == 'yes' ? 'yes' : 'no';
		$delete				= isset($_POST['delete']) && $_POST['delete'] == 'yes' ? 'yes' : 'no';

		if ($message == '') {
			error('Your message did not contain any content!');
		}

		$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_subscriptions WHERE user_id = $post[user_id] AND topic_id = $post[topic_id])");

		if ($delete == 'yes') {
			output('Your post has been successfully deleted!');

			if ($post['is_first'] == 1) {
				$result = $db->query("SELECT user_id FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				while ($user = $db->fetch_array($result)) {
					$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $user[user_id]");
				}

				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_topics WHERE topic_id = $post[topic_id]");
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE topic_id = $post[topic_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name']), 2);
			} else {
				$db->query("DELETE FROM " . $config['db']['prefix'] . "forum_posts WHERE post_id = $post_id");
				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET num_replies = num_replies - 1 WHERE topic_id = $post[topic_id]");
				$db->query("UPDATE " . $config['db']['prefix'] . "users SET num_posts = num_posts - 1 WHERE user_id = $post[user_id]");

				redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject']), 2);
			}

			update_forum($post['forum_id']);
		} else {
			$db->query("UPDATE " . $config['db']['prefix'] . "forum_posts SET ad_type = '$ad_type', pet_type = '$pet_type', breed = '$breed', gender = '$gender', colours = '$colours', dob = '$dob', available = '$available', price = '$price', message = '$message' WHERE post_id = $post_id");

			if ($subscribe == 'yes') {
				$db->query("INSERT INTO " . $config['db']['prefix'] . "forum_subscriptions (user_id, topic_id) VALUES ($post[user_id], $post[topic_id])");
			}

			if ($post['is_first'] == 1) {
				$subject			= isset($_POST['subject']) ? check_input($_POST['subject']) : '';
				$topped				= isset($_POST['topped']) && $_POST['topped'] == 'yes' && ($user_data['group_id'] == GROUPS_ADMIN || $user_data['group_id'] == GROUPS_MOD) ? 1 : 0;

				$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET subject = '$subject', topped = $topped WHERE topic_id = $post[topic_id]");
			}

			output('Your post has been successfully updated! Please wait while we redirect you to your post.');
			redirect('/forum/' . get_url_forum($post['forum_id'], $post['forum_name'], $post['topic_id'], $post['subject'],  $post_id), 2);
		}
	}
}

// Move Topic

if (isset($_GET['action']) && $_GET['action'] == 'move_topic') {
	if ($user_data['group_id'] != GROUPS_ADMIN && $user_data['group_id'] != GROUPS_MOD) {
		error('You do not have permission to move this topic!');
	}
	
	$db->query("UPDATE " . $config['db']['prefix'] . "forum_topics SET forum_id = $forum_id WHERE topic_id = $topic_id");
	
	output('Topic has been successfully moved!');
	redirect('/forum/', 2);
}

// Mark topics as read

if (isset($_GET['action']) && $_GET['action'] == 'mark_read') {
	if ($forum_id == 0) {
		// Loop through all forums and create cookie
		
		$result = $GLOBALS['db']->query("SELECT forum_id FROM " . $GLOBALS['config']['db']['prefix'] . "forum_forums WHERE status = 1");
		
		foreach (fetch_array($result) as $forum) {
			setcookie('f_' . $forum['forum_id'], time(), time() + 86400, $config['cookie']['path'], $config['cookie']['domain']); // 1 day
		}
	
		output('Topics successfully marked as read!');
		redirect('/forum/', 2);
	} else {
		setcookie('f_' . $forum_id, time(), time() + 86400, $config['cookie']['path'], $config['cookie']['domain']); // 1 day
	
		output('Topics successfully marked as read!!');
		redirect('/forum/' . get_url_forum($forum_id, ''), 2);
	}
}

echo $tpl->fetch('forum.tpl.php');

?>

Do you have the below attribute defined on the form element?

<form enctype=“multipart/form-data”>

Do you know, I was just about to post to say I have just added that and that has solved one issue - I no longer get that issue.

The next problem now is:

Notice: Undefined variable: image_name in /home/www/forum/post.php on line 111

One after another - bloody pain!

Right, solved that issue now - so no worries on that one.

My problem now is :(:(:frowning: when the post is submitted, that none of the text from the other fields is showing - which was working fine before.