I say it fails because it doesn't run the savephoto process when the form is return on itself.
The code below runs if the Upload Photos is clicked but not if Enter is pressed after the caption field.
if (isset($savephoto))
{
$division="$_POST[hpg_division]";
$hpg_caption="$_POST[hpg_caption]";
$uploadedfile="$_POST[uploadedfile]";
$hpg_username="$_POST[hpg_username]";
echo "Division: $division<p>";
echo "Caption: $hpg_caption<p>";
echo "uploadedfile: $uploadedfile<p>";
echo "Username: $hpg_username<p>";
die();
uploading script;
adding to db script;
etc. etc. etc.
Edit:
Got it working by placing ?savephoto in here:
echo "<form method=\"post\" action=\"$_SERVER[PHP_SELF]?savephoto\" enctype=\"multipart/form-data\"> \n";
Thanks