Hi, I've got a pretty straight forward foreach statement, which is capturing fields from a form and storing their names as variables. It then creates a session variable for each of them. This seems to work, as when I echo $_SESSION['$key'] inside the foreach statement it displays all the field values. However, when I attempt to echo one of these values outside the foreach (here the variable is called fname, which is definately one of the field names) nothing comes up. Thankyou in advance to whoever ends my frustrator by pointing out what's at fault here 🙂
<?php
session_start();
foreach($_POST as $key=>$value){
$_SESSION['$key']=$value;
}
echo $_SESSION['fname'];
?>