alanl1 Posted June 11, 2013 Share Posted June 11, 2013 I have a form <form method='POST' name="myform" action="test.php?filename=$filename" > when I try to retrieve the variable I get nothing. My browser just shows this http://localhost/test.php?filename=$filename $newfilename = $_POST[$filename]; echo " the filename is ".$newfilename; the filename is Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/ Share on other sites More sharing options...
requinix Posted June 11, 2013 Share Posted June 11, 2013 You can't use variables in literal HTML and just expect PHP to know that you want it replaced. You have to use PHP code for it. Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435255 Share on other sites More sharing options...
alanl1 Posted June 11, 2013 Author Share Posted June 11, 2013 wow that was fast. i have tried that which sort of works, it shows in the browser ok now I still cannot seem to echo this out on the next page though, am i doing something else wrong $newfilename = $_POST[$filename]; echo " the filename is ".$newfilename; Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435256 Share on other sites More sharing options...
AbraCadaver Posted June 11, 2013 Share Posted June 11, 2013 $newfilename = $_POST['filename']; Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435259 Share on other sites More sharing options...
alanl1 Posted June 11, 2013 Author Share Posted June 11, 2013 ok ive done that <?php $newfilename = $_POST['filename'];echo " the filename is ".$newfilename; ?> and it still shows nothing, I can see it in the browser http://localhost/test.php?filename=Synergy_SARnew.csv Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435273 Share on other sites More sharing options...
requinix Posted June 11, 2013 Share Posted June 11, 2013 (edited) Nothing as in an empty filename? $_POST is for forms with $_GET is for URLs. That's the one you want to use. Edited June 11, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435284 Share on other sites More sharing options...
Solution alanl1 Posted June 11, 2013 Author Solution Share Posted June 11, 2013 thanks that works Quote Link to comment https://forums.phpfreaks.com/topic/279020-variable-not-passing-through/#findComment-1435434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
× Pasted as rich text. Restore formatting
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a link instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.