NameSilo

Help w/ $_POST in PHP

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

Outer

Established Member
Impact
2
Heres my problem, I have a bunch of variables sent from a form that takes on the look:

planet1
planet2
planet3
planet4
planet5
ect.
ect.
ect.

heres the IF statement that it is sent to:
PHP:
IF ($_POST[Submit] == "Submit") {
   for ($a = "1"; $a <= "380"; $a++) {
     $planet = $_POST[planet$a];

   }
}

I get the error: Parse error: parse error, unexpected T_VARIABLE, expecting ']' in www\hyps\allocation_map.php on line 24

so, my question to you is, how do I have the variable $a inside of the _POST variable?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Put single quotes around the post variable:
PHP:
$_POST['planet$a'];
 
0
Close
To be honest the best way going about doing this would be to set the names to planet[] rather than planet1, ect. This will create an array of all the input and would make everything much easier to maintain.
 
0
Close
ah, gotchya creative ;)

i did it that way and it worked much better, thx :)
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back