I am trying to pass a variable thorugh HTML anchor tag thorugh form. On form submit the value in anchor is passed to my .php file . Here in php file I have stored the passed value in a variable and now I want to use this value in header.
index.html
In below HTML I am passing variable "text1.pdf" to form.php
<a href="#" title="Download" target="_blank" onclick="document.myform.formVar.value='text1.pdf';document.myform.submit(); return false">Download</a>
<form method=post name="myform" action="form.php" style="display:none;">
<input type="hidden" name="formVar" value="">
<input type="submit" value="Send form!">
Form.php
$fileName = $_POST['formVar'];
// Defining file URL
$fileURL="pdf/";
$fileURL .=$fileName;
header( "Location: ".$fileURL);
Here I am trying to form a URL using passed variable. And trying to put that variable in header. But I am not able to reach to that specific file. When I submit form on form.php it gets redirected to "pdf/" url instead of "pdf/text.pdf" .