doforumda Posted November 19, 2009 Share Posted November 19, 2009 hi i create form. what this does is when the user come to the page he has to enter the number of fields that how many input fields he needs. he type e.g, 5 then press go. so 5 input fields will be appear. then what i want is how can i name these inputs so when the user completes and press submit so that the values will be processed to php side and echo out these names. my code is below <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="post" action="dynamicFields.php"> <input name="numfields" type="text" size="3" maxlength="3" /> <input type="submit" name="fields" value="GO" /> </form> <?php if(isset($_POST['fields'])) { $numfields = $_POST['numfields']; if(is_numeric($numfields)) { for($i = 1; $i <= $numfields; $i++) { ?> <form enctype="multipart/form-data" method="post" action="uploadtutorial.php"> <label>Description:</label> <input type="text" name="desc" /><br /> <label class="upload">Choose File:</label> <input type="file" name="uploadedfile" id="file" /><br /> <?php } } else die("The input must be a number."); } ?> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> the process these values code is here <?php if($_POST['submit']) { $description = $_POST['desc']; $filename = $_FILES['uploadedfile']['name']; echo $description."<br>"; echo $filename; } ?> Link to comment https://forums.phpfreaks.com/topic/182124-need-help-in-naming-and-posting-input-fields/ Share on other sites More sharing options...
ram4nd Posted November 19, 2009 Share Posted November 19, 2009 name like: field1,field2,field3 and you can use hidden field to hold the number of the fields Link to comment https://forums.phpfreaks.com/topic/182124-need-help-in-naming-and-posting-input-fields/#findComment-960839 Share on other sites More sharing options...
doforumda Posted November 19, 2009 Author Share Posted November 19, 2009 let me make this simple. how can i upload multiple files? i want to upload multiple files. please help me in above code thanks Link to comment https://forums.phpfreaks.com/topic/182124-need-help-in-naming-and-posting-input-fields/#findComment-960845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.