corbeeresearch Posted August 24, 2010 Share Posted August 24, 2010 Hi guys, Is there an html code that allows you to array a form input? and once you passed the form, how do you extract the data then insert it to the database? Thanks Link to comment https://forums.phpfreaks.com/topic/211576-creating-and-passing-form-array/ Share on other sites More sharing options...
Pikachu2000 Posted August 24, 2010 Share Posted August 24, 2010 You're going to need to elaborate a little more on this. What exactly are you trying to do? An example would probably be a good idea. Link to comment https://forums.phpfreaks.com/topic/211576-creating-and-passing-form-array/#findComment-1102982 Share on other sites More sharing options...
corbeeresearch Posted August 24, 2010 Author Share Posted August 24, 2010 I'm trying to do a multi-page registration form, which includes allowing the user to enter the name of their car(registered name, plate number, year manufactured, brand, model, then what club, then a couple of radio buttons with yes or no answer). If they have more than one car, they can click add a new car, then they will be able enter another car information. So I was thinking of form array, but how do I create form arrays, then pass them to php using post? Link to comment https://forums.phpfreaks.com/topic/211576-creating-and-passing-form-array/#findComment-1102999 Share on other sites More sharing options...
ceycey Posted August 24, 2010 Share Posted August 24, 2010 sending values inside an array is possible... <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="carname[]" value="car name1" /><br /> <input type="text" name="carname[]" value="car name2" /><br /> <input type="submit" name="cars" value="send" /> </form> <?php if(isset($_POST['cars'])) { foreach($_POST['carname'] as $item) echo "$item <br />"; } ?> You can write a javascript function which appends a new input control to the document, like "<input type="text" name="carname[] />" />" when "add buton" is clicked... Link to comment https://forums.phpfreaks.com/topic/211576-creating-and-passing-form-array/#findComment-1103001 Share on other sites More sharing options...
corbeeresearch Posted August 24, 2010 Author Share Posted August 24, 2010 Thanks! Link to comment https://forums.phpfreaks.com/topic/211576-creating-and-passing-form-array/#findComment-1103003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.