03-30-06, 10:50 AM
Newbie Coder
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Submitting form sends file, but not $_POST data, to database
Can anyone tell me what's wrong with this code? The file uploads just fine, and the file info (path, size, type, name) are added to the database properly. But everything else (all the $_POSTs) do not submit to the database. Any ideas?
PHP Code:
<?
$uploadDir = 'C:/Inetpub/wwwroot/upload/' ;
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 );
$fileUser = $_POST [ 'fileUser' ];
$filePub = $_POST [ 'filePub' ];
$fileDestination = $_POST [ 'fileDestination' ];
$fileRuns = $_POST [ 'fileRuns' ];
$fileNotes = $_POST [ 'fileNotes' ];
if (! $result ) {
echo "Error uploading file" ;
exit;
}
include 'include/config.php' ;
include 'include/opendb.php' ;
if(! get_magic_quotes_gpc ())
{
$fileName = addslashes ( $fileName );
$filePath = addslashes ( $filePath );
}
$query = "INSERT INTO upload (name, type, size, path, user, pub, destination, runs, notes) VALUES (' $fileName ', ' $fileType ', ' $fileSize ', ' $filePath ', ' $fileUser ', ' $filePub ', ' $fileDestination ', ' $fileRuns ', ' $fileNotes ')" ;
mysql_query ( $query ) or die( 'Error, query failed : ' . mysql_error ());
include 'include/closedb.php' ;
echo "<br>File uploaded<br>" ;
}
?>