Current location: Hot Scripts Forums » Programming Languages » PHP » Submitting form sends file, but not $_POST data, to database


Submitting form sends file, but not $_POST data, to database

Reply
  #1 (permalink)  
Old 03-30-06, 10:50 AM
GodsHand GodsHand is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Smile 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>";
}
?>
Code:
		<form action="" method="post" enctype="multipart/form-data" name="uploadform">
		<span class="left">Choose your file:</span>
		<span class="right">
			<input type="hidden" name="MAX_FILE_SIZE" value="500000000">
			<input type="hidden" name="fileUser" id="fileUser" value="<?=$session->username?>">
			<input name="userfile" type="file" class="box" id="userfile">
		</span>
		
		<br />
		
		<span class="left">Publication:</span>
		<span class="right">
			<select name="filePub" id="filePub">
				<option selected="selected">Choose...</option>
				<option value="Special Sections">Special Sections</option>
			</select>
		</span>
		
		<br />
		
		<span class="left">Destination:</span>
		<span class="right">
			<select name="fileDestination" id="fileDestination">
				<option selected="selected">Choose...</option>
				<option value="Advertising">Advertising</option>
			</select>
		</span>
		
		<br />
		
		<span class="left">Runs:</span>
		<span class="right">
			<input class="input" name="fileRuns" id="fileRuns"> <img src="media/datebutton.png" alt="" 
			onclick="displayDatePicker('fileRuns');" class="datebutton" />
		</span>
		
		<br />
		
		<span class="left">Notes:</span>
		<span class="right"><textarea name="fileNotes" id="fileNotes" cols="40" rows="5" wrap="physical"></textarea>
		
		<br />
		
		<input name="upload" type="submit" class="box" id="upload" value="  Upload  "></span>
		</form>
Reply With Quote
  #2 (permalink)  
Old 03-30-06, 11:38 AM
GodsHand GodsHand is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Nevermind, I figured out that I wasn't posting to index.php. Works great.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP upload prob minority ASP 1 06-27-05 08:35 AM
Write form data to file dragge PHP 1 12-27-03 07:26 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM


All times are GMT -5. The time now is 07:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.