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 Quote 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 Quote 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" Quote 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. Quote 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? Quote 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 @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. Quote 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 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. Quote 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 (edited) Quoted wrong post. Edited May 18, 2013 by Andy-H Quote 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 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. Quote 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 @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>";?> Quote 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 (edited) 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> Edited May 21, 2013 by Eiseth Quote Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1431302 Share on other sites More sharing options...
Solution alanl1 Posted May 22, 2013 Author Solution Share Posted May 22, 2013 I used PBS's first reply and it worked, thanks Quote Link to comment https://forums.phpfreaks.com/topic/278012-passing-variables-via-redirect/#findComment-1431724 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.