Unstoppable Domains

Please help clarify logistics

Spaceship Spaceship
Watch

SquireQuack

Established Member
Impact
0
I'm scripting a form in HTML and PHP. I need to have a link that adds extra fields , named inputX when when click.

My problem is, how do display all fields using $_POST['inputX']?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
The name of the field should be like this:

<input name="inputX[]">

PHP will automatically create an array and you can use it when you process it. Be warned that if a user skips a field (e.g. leaves one blank), and goes to fill out the next one, it will IGNORE the empty fields, meaning it won't even make them part of the array.
 
0
•••
Thanks for the help!

Got a another question.

What's the best way to add more fields?
I'm a little unfamiliar with using the "?act" in /doc.php?act=action or do=action

how does that exactly work? How do I define what it does?
 
0
•••
In a URL, any text after a ? character is declaring variables.

file.php?variable=value&variable2=another_value

Use it as sparingly as you can as it presents security problems. You can then retrieve the variables in PHP like this:

$variable = $_GET['variable'];


Otherwise, the best way to add more fields is to use JavaScript, which would be instant as soon as you click a link or button. Or, you could use PHP and reload the page, but you need to find a way to keep the values. I recommend javascript.
 
0
•••
As compuXP said, I also reccomend JavaScript to add fields instantly. The only problem I see, though, is if javascript is disabled. Although it doesn't seem likely, a lot of users actually have javascript disabled (either manually, by an antivirus program, etc).

Maybe if you could detect if javascript is enabled on the client's computer, and then display the preffered way.
 
0
•••
At least display a notice that Javascript is required... if you really want compatibility make it detect if it's enabled - if not then do it slowly by a PHP reload.
 
0
•••

We're social

Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back