I can't get my file to upload. Other than that, my script works fine.
<?php
$db = JFactory::getDBO();
$form=$_POST['urnform'];//figuring out which form is submitted
$urnid=$_POST['urnid'];//getting case #
$urncompany=$_POST['urncompany'];
if($urncompany == "1")
$urncompanyname = "batesvilleurns";//Batesville
elseif($urncompany == "3")
$urncompanyname = "batesvilleurns";//Batesville with 300 X 235 pic size
elseif($urncompany == "4")
$urncompanyname = "auroraurns";//Aurora
elseif($urncompany == "6")
$urncompanyname = "churchchapel";//Church & Chapel
elseif($urncompany == "7")
$urncompanyname = "crescent";//Crescent
elseif($urncompany == "2")
$urncompanyname = "infinityurns";//Kelco
elseif($urncompany == "8")
$urncompanyname = "madelyn";//Madelyn
else
$urncompanyname = "matthewsurns";//Matthews
//if($casketcompany2 == "1")
//$prefix = "a";//Aurora
//else
$prefix = "";//the rest
if($form == "Delete Urn")
echo "";
else
{
$HTTP_POST_FILES['userfile']['tmp_name'];
$HTTP_POST_FILES['userfile']['name'];
$HTTP_POST_FILES['userfile']['size'];
$HTTP_POST_FILES['userfile']['type'];
if($userfile == "none")
{
echo "Problem: no file uploaded";
exit;
}
if($userfile_size=="0")
{
echo "Problem: uploaded file is zero length";
exit;
}
//if($userfile_type != "text/plain")
//{
// echo "Problem: file is not plain text";
// exit;
//}
//if(!is_uploaded_file($userfile))
//{
// echo "Problem: possible file upload attack";
// exit;
//}
$upfile="images/$urncompany/$urnid.jpg";
//if(!copy($userfile,$upfile))
//{
// echo "Problem: Could not move file into directory";
// exit;
//}
copy($userfile,$upfile);
//echo "File uploaded successfully<br><br>";
//$fp=fopen($upfile, "r");
//$contents=fread($fp,filesize($upfile));
//fclose($fp);
//$contents=strip_tags($contents);
//$fp=fopen($upfile,"w");
//fwrite($fp,$contents);
//fclose($fp);
}
$photo="images/$urncompanyname/$prefix$urnid.jpg";
//update record
if($form == "Edit Urn")
$query ="UPDATE urns SET urnid='$urnid', material='$_POST[material]', picture='$photo', name='$_POST[name]',
price='$_POST[price]', feature1='$_POST[feature1]', feature2='$_POST[feature2]', materialid='$_POST[materialid]',
dimensions='$_POST[dimensions]', urncompany='$urncompany', capacity='$_POST[capacity]', series='$_POST[series]',
active='$_POST[active]' where urnid = '$urnid'";
//line 70
//Delete Record
elseif($form == "Delete Urn")
$query = "DELETE from urns where urnid = '$urnid'";
//insert record
elseif($form == "Add Urn")
$query ="INSERT INTO urns (urnid, material, picture, name, price, feature1, feature2, materialid,
dimensions, urncompany, capacity, series, active)
VALUES
('$urnid','$_POST[material]','$photo','$_POST[name]','$_POST[price]',
'$_POST[feature1]','$_POST[feature2]','$_POST[materialid]','$_POST[dimensions]','$urncompany','$_POST[capacity]',
'$_POST[series]','$_POST[active]')";
else
print "no form entered";
$result = mysql_query($query)
or die("Couldn't execute sql.");
if($form == "Edit Urn")
echo "<center>The <b><u>$_POST[name]</b></u> record has been updated.</center>";
elseif($form == "Delete Urn")
echo "<center>The <b><u>$_POST[name]</b></u> record has been deleted.</center>";
elseif($form == "Add Urn")
echo "<center>A record for <b><u>$_POST[name]</b></u> has been added. $_POST[userfile_name]</center>";
else
echo "Ain't Nuthin Happn'in";
?>