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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
corbeeresearch Posted August 24, 2010 Author Share Posted August 24, 2010 Thanks! Quote Link to comment 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.