alanl1 Posted May 15, 2013 Share Posted May 15, 2013 Hi Professionals I have the following piece of code on my Upload page <td width="33%" align="left"> <?php if ($result==1) header("Location: import1.php?$imagename"); ?></td> which then goes to import1.php in my browser address bar it shows http://localhost/import1.php?uploads/ExtTypes Test.csv In my import1.php file i have the following code which shows nothing? echo "the filename is " . $imagename; Alll it shows is "the file name is" any ideas? thanks in advance Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/ Share on other sites More sharing options...
PravinS Posted May 15, 2013 Share Posted May 15, 2013 Using query string, you need to use key=value way of passing values like <td width="33%" align="left"> <?php if ($result==1) header("Location: import1.php?imagename=$imagename"); ?></td> and in import1.php page you need to get the value using GET method like this $imagename = $_GET['imagename']; echo "the filename is " . $imagename; may this will help you Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430132 Share on other sites More sharing options...
alanl1 Posted May 15, 2013 Author Share Posted May 15, 2013 now my url just shows http://localhost/import1.php?uploads/ExtTypesTest.csv=uploads/ExtTypesTest.csv in the import1.php page and still shows "the filename is" Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430137 Share on other sites More sharing options...
Q695 Posted May 15, 2013 Share Posted May 15, 2013 The header items must go before the client sees anything AT ALL. Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430287 Share on other sites More sharing options...
mac_gyver Posted May 15, 2013 Share Posted May 15, 2013 @Q695, a number of your replies in threads have nothing to do with the problem in the thread. are you even reading and understanding what is being asked? Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430297 Share on other sites More sharing options...
Q695 Posted May 18, 2013 Share Posted May 18, 2013 On 5/15/2013 at 7:32 PM, mac_gyver said: @Q695, a number of your replies in threads have nothing to do with the problem in the thread. are you even reading and understanding what is being asked? When using the header tag, and passing data it uses the redirect function, unless they want it in the address bar, then it's $_GET. Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430843 Share on other sites More sharing options...
Jessica Posted May 18, 2013 Share Posted May 18, 2013 On 5/18/2013 at 5:17 PM, Q695 said: When using the header tag, and passing data it uses the redirect function, unless they want it in the address bar, then it's $_GET. So, no. OP: Post your updated code so we can see what you did. Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430848 Share on other sites More sharing options...
Andy-H Posted May 18, 2013 Share Posted May 18, 2013 Quoted wrong post. Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430855 Share on other sites More sharing options...
Andy-H Posted May 18, 2013 Share Posted May 18, 2013 On 5/15/2013 at 7:09 PM, Q695 said: The header items must go before the client sees anything AT ALL. He has a valid point here, the OP posted code that attempts a header redirect after outputting a td tag, without output buffering, this will cause the header call to fail. Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1430856 Share on other sites More sharing options...
Q695 Posted May 21, 2013 Share Posted May 21, 2013 On 5/15/2013 at 7:32 PM, mac_gyver said: @Q695, a number of your replies in threads have nothing to do with the problem in the thread. are you even reading and understanding what is being asked? Some people don't know how to use a header, or how to use a <a href> tag. If my reply has nothing to do with the question, then use a <?php echo "<a href='import1.php?$imagename'>link text</a>";?> Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1431296 Share on other sites More sharing options...
Eiseth Posted May 21, 2013 Share Posted May 21, 2013 On 5/15/2013 at 5:32 AM, alanl1 said: now my url just shows http://localhost/import1.php?uploads/ExtTypesTest.csv=uploads/ExtTypesTest.csv in the import1.php page and still shows "the filename is" Is this after you submit your form? Can you post your form and import1.php? Are you using enctype="multipart/form-data in your form? <form action="import1.php" method="POST" enctype="multipart/form-data">...</form> Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1431302 Share on other sites More sharing options...
alanl1 Posted May 22, 2013 Author Share Posted May 22, 2013 I used PBS's first reply and it worked, thanks Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1431724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.