NameSilo

Help w/ $_POST in PHP

SpaceshipSpaceship
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
•••
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
•••
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
•••
ah, gotchya creative ;)

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

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back