I am trying to assign a value to a variable from a selection in a list box generated by the following code:
Then I want to include the file selected from above, in the rest of the file (files contain variables used to populate text fields in a form)
Something like:
I do not want to include anything, if no file is selected (or the variable $filea is not set)..
I am having trouble with this.. can anyone help?
Code:
<form action="rateadmin.php" method="post">
<select name="file">
<? $folder = "rates/";
$handle = opendir($folder);
while ($file = readdir($handle))
{
$files[] = $file;
}
closedir($handle);
foreach ($files as $file) {
print "<option value=$folder$file>$file</option>";
}
?>
</select><input name="" type="submit" value="Get File" />
</form>
Then I want to include the file selected from above, in the rest of the file (files contain variables used to populate text fields in a form)
Something like:
Code:
$filea = addslashes($_POST['file']);
if (isset($filea)) {
include $filea;
}
I am having trouble with this.. can anyone help?