help with forms upload file simultaneously with post data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
atdawgie
Forum Newbie
Posts: 1
Joined: Thu Apr 06, 2006 12:44 pm

help with forms upload file simultaneously with post data

Post by atdawgie »

Hi, I'm trying to upload a file where I use the HTTP_POST_FILES array but also need to pass POST data that is in another form on the same page. How do I pass data from both forms at the same time, or is it possible to encorporate the two forms together? My understanding is when I click the upload button it will only pass HTTP_POST_FILES and not regular POST data? I tried using the javascript onclick() function so when I click the upload button on the files form it also clicks the button on the post form but that didn't work for some reason?




Thanks,
Aaron

Code: Select all

<html>

<head>
<script language="JavaScript">

function test1(form) {


document.form1.update.click();

 }

 </script>


<title>Edit Findings</title>



<style>



.bg {color: white;.background-color: navy}



</style>



</head>



<body>
<h3>Edit Findings</h3>


<?php
//connect to db;

include('findings.inc');

//error_reporting(0);

//instantiate class
$mydb = new Findings();

//connect to db
$mydb->SQL_connect();

$tablename = "study_findings";

//select fields of study selected
$cur1 = MYSQL_QUERY ("select * from $tablename where study_id_fk = '$study_id' AND sf_id='$sf_id'");

$short_title = stripslashes($short_title);

echo "<h4><i>$short_title</i></h4>";
//loop through results to display
while ($row = mysql_fetch_array($cur1, MYSQL_ASSOC)) {

//display individual study for editing

?>

<form name="form1" method="post" action="update.php">
<table width="75%" border="1">
  <tr>
    <td align=top>Citation</td>
    <td> <TEXTAREA NAME="citation" ROWS="3" COLS="67"><?php echo $row['citation']; ?></TEXTAREA></td>
  </tr>
  <tr>
    <td>Finding Type</td>
    <td>

	<?php

	if ($row['publications']) {
    	echo "<input type='checkbox' name='publications' checked>publications";
    }
    else {
		echo "<input type='checkbox' name='publications'>publications";
	}
	if ($row['reports_briefs']) {
    	echo "<input type='checkbox' name='reports_briefs' checked>reports & briefs";
    }
    else {
		echo "<input type='checkbox' name='reports_briefs'>reports & briefs";
	}
	if ($row['presentations']) {
    	echo "<input type='checkbox' name='presentations' checked>presentations";
    }
    else {
		echo "<input type='checkbox' name='presentations'>presentations";
	}
	if ($row['other']) {
    	echo "<input type='checkbox' name='other' checked>other";
    }
    else {
		echo "<input type='checkbox' name='other'>other";
	}
    ?>
	</td>
  </tr>
  <tr>
  	<td>Citation Date</td>
  	<td><input type="text" name="citation_date" value="<?php echo $row['citation_date']; ?>"></td>
  </tr>
  <tr>
    <td><p>Date Entered</p></td>
    <td><?php echo $row['date_entered']; ?></td>
  </tr>
  <tr>
    <td><p>Date Modified</p></td>
    <td>Automatic</td>
  </tr>
  <tr>
    <td><p>Blank Space</p></td>
    <td><input type="text" name="blank_space" value="<?php echo $row['blank_space']; ?>"></td>
	<td><input type='hidden' name='short_title' value='<?php echo $short_title; ?>'></td>
	<td WIDTH = 50><INPUT TYPE='HIDDEN' NAME='study_id' value="<?php echo $study_id; ?>"></TD>
	<td WIDTH = 50><INPUT TYPE='HIDDEN' NAME='sf_id' value="<?php echo $sf_id; ?>"></TD>
  </tr>
  <tr>
	<td ALIGN=LEFT WIDTH=120></td><td align=right><INPUT TYPE="submit" NAME="update" VALUE="Update"> <INPUT TYPE="SUBMIT" NAME="delete" VALUE="Delete"></td>
  </tr>
</table>
</form>

<table width="75%" border="1">
  <tr>
	<td>
	</form>
	<form enctype="multipart/form-data" action="update.php" method="POST">
	<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
	Choose a file to upload: <input name="uploadfile[]" value="uploadfile" type="file" /><br />
    Upload one pager: <input name="uploadfile[]" value="onepager" type="file" /><br />
	</td>
   <tr>
     <td align=right width=100><input type="submit" name="upload" value="Upload File" onClick="test1(this.form);"></td>
   </tr>
   </form>
</table>

</body>
</html>

<?php

}  //end mysql_fetch_array


?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It is not possible to submit two separate forms at the same time. Combine them into a single form.
Post Reply