I've completely tugged all of my hair out on this one. I'm using a PHP script to upload a file to my server, save the information in SQL, then allow me to download the file. I wanted to give the download a description, so I added a table to the database and "attempted" to adjust the form. No matter what I try, when I input something into the description field on the form, it never ends up in my database. Any ideas?
<html>
<head>
<title>Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.box {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border: 1px solid #000000;
}
a {
color: #00FF00;
}
a:visited {
color: #00FF00;
}
a:active {
color: #00FF00;
}
a:hover {
color: #00FF00;
}
-->
</style>
</head>
<body style="color: #00FF00; background-color: #000000">
<?
$uploadDir = '/home/hookah17/public_html/sniper/upload/downloads/';
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include 'inc/config.php';
include 'inc/opendb.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO upload (name, size, type, path, dis) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$dis')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
include 'inc/closedb.php';
echo "<br>File uploaded<br>";
}
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="350" border="2" cellpadding="1" cellspacing="1" class="box">
<tr> Description:<br>
<input type="text" name="dis" size="40">
<td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
</body>
</html>