tarnfeld
tarnfeld

Reputation: 26556

$_SESSION up all $_POST variables?

Is there any way to do some kind of while() for each post variable and session it up... like in mysql

while($row=mysql_fetch_array($result)){
echo($row['name'];
}

But to get this result with the $_POST

while($_POST){
$_SESSION['BLA'] = $_POST['BLA'];
}

Upvotes: 1

Views: 649

Answers (2)

TigerTiger
TigerTiger

Reputation: 10806

foreach($_POST as $key => $value){
echo $key . ' = ' .$value. ' <br />';
 // do whatever you want to do with these variables
}

Or

just for example, if you just want to put all of those in $_POST into $_SESSION

$_SESSION['MyPost'] = $_POST;

Upvotes: 3

Luca Matteis
Luca Matteis

Reputation: 29267

foreach($_POST as $i=>$v){
    $_SESSION[$i] = $_POST[$i];
}

Upvotes: 1

Related Questions