mpsn Posted November 12, 2011 Share Posted November 12, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/250978-how-do-i-get-info-bt-three-linked-pages/ Share on other sites More sharing options...
xProteuSx Posted November 12, 2011 Share Posted November 12, 2011 On your second page use this code: session_start(); $_SESSION['num_uploads'] = $_POST['numberFromFirstPageForm']; Then on your third page you can use this variable as follows: session_start(); echo $_SESSION['num_uploads']; Quote Link to comment https://forums.phpfreaks.com/topic/250978-how-do-i-get-info-bt-three-linked-pages/#findComment-1287544 Share on other sites More sharing options...
xProteuSx Posted November 12, 2011 Share Posted November 12, 2011 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']; Quote Link to comment https://forums.phpfreaks.com/topic/250978-how-do-i-get-info-bt-three-linked-pages/#findComment-1287545 Share on other sites More sharing options...
mpsn Posted November 12, 2011 Author Share Posted November 12, 2011 That was simple! Just a question, so basically I am using an associative array where input tag's attribute is the name attribute with key/value being value attribute, is that right? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/250978-how-do-i-get-info-bt-three-linked-pages/#findComment-1287550 Share on other sites More sharing options...
mpsn Posted November 15, 2011 Author Share Posted November 15, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/250978-how-do-i-get-info-bt-three-linked-pages/#findComment-1288231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.