Jump to content

how do i get info b/t three linked pages


mpsn

Recommended Posts

Hi, I want to be able to allow user to enter in <input type="text" >... the total XML files to upload on the first page so:

 

my first page has form that asks user how many uploads form they want so (firstpage.html):

<form method='post' action='outputTotalUploads.php' >...

 

Then in second form (outputTotalUploads.php) is where it outputs the desired number of upload forms based on the first page:

for loop to post each <form method='post' action='addToDb.php' >...

 

Finally in third page (addToDb.php):

for each uploaded file, do: //BUT HOW DO I GET THIS TOTAL??

  add to database

 

*My problem is HOW do I refer to the total number of uploads the user chose way back in the first page b/c I know you cannot have multiple action attribute in the form tag.

 

Any help much appreciated!

 

Link to comment
Share on other sites

Forgot to mention:  the solution I posted previously uses sessions and session variables.  You can also put a hidden input on the second page, and re-use the variable on the third, like this:

 

<?php

echo '<input type="hidden" name="num_uploads" value="' . $_POST[numberFromFirstPageForm] . '" />';

?>

 

Then you can claim it on the third page by calling up the variable like this:

 

echo $_POST['num_uploads'];

 

 

Link to comment
Share on other sites

Hi, now I have a new problem, I don't know why the $_POST array is empty when I have uploaded content. I have three scripts (1st: ask users how many upload pairs they want (an XML file must be accompanied by an XSD file; 2nd: dispaly the total upload form pairs; 3rd: the upload pairs with content user uploaded will be validated before storing to db)

 

First script: (ask user to enter total number upload pairs)

=======

<?php

<form method="DisplayMultipleUploads.php" action="post">

<input type="text" name="numUploadPairs" />

<input type="submit" name="SUBMIT"  name="numUploadPairsSubmit"/>

</form>

 

if(array_key_exists("numUploadPairsSubmit", $_POST) && !empty($_POST["numUploadPairs"])) {

  header("Location: showUploadForms.php");

  exit;

}

?>

 

Second script: (showUploadForms.php):

============================

<?php

$numUploadPairs=$_POST["numUploadPairs"];

print "<form action='storeToDB.php' method='post' enctype='multipart/form-data'>";

for($i=0;$i<$numUploadPairs;$i++) {

print

'<p>

<label>

Upload XSD file #'.$i; print '<input type="file" name="uploadedXSDFile".'.$i; print 'value="uploadedXSDFileValue" id="imageFileType" />

</label>

</p>i

<p>

<label>';

print 'Upload an XML file #'.$i; print '<input type="file" name="uploadedXMLFile"'.$i; print 'value="uploadedXMLFileValue" id="imageFileType" />

</label>

<input type="hidden" name="numUploadsHidden" value=';print $numUploadPairs; print '/>

</p>';

print "-----------------------------------------------------------<br />";

}//END WHILE LOOP for build XSD:XML upload form pairs

print

"<p>

<input type='submit' name='multipleUploadSubmit' value='STORE to DB NOW'/>

</p>";

print '</form> <br />';

 

?>

 

Third script: (storeToDB.php):

=====================

<?php

//user's total desired upload pairs

$numActualUploads=chop($_POST["numUploadsHidden"], "/");//chop removes char to right of first param string

 

//TEST to make sure $_POST['uploadedXSDFile'.i] and $_POST['uploadedXMLFie'.i] exist

for($i=0;$i<$numActualUploads;$i++) {

 

//ONLY print the uploaded forms where XSD:XML pairs BOTH HAVE ACTUAL CONTENT!

if(!empty($_POST['uploadedXSDFile'.$i])

&& !empty($_POST['uploadedXMLFile'.$i]) ) {

print 'cur XSD:'.$_POST['uploadedXSDFile'.$i].':';

print 'cur XML:'.$_POST['uploadedXMLFile'.$i];

}

else

print "Nay <br />";

}

?>

 

For the third script, I thought I check first if the $_POST even have uploaded content, it turns they don't, so it just prints: "Nay"

 

Any help much appreicated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.