rfeio Posted August 21, 2008 Share Posted August 21, 2008 Hi, I'm trying to redirect the one of my page to another site where I need to pass some values to. An example of the code I'm using: $url = 'http://'.$site.'?form='.$form; when I echo the variable $url I get: http://www.website.com?form=123 when I try to do the redirection using the header function: header("Location: $url"); the result is: http://www.website.com/?form=123 which doesn't redirect me the correct way. How can I solve this? Thanks! Rfeio Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 http://www.website.com?form=123 is not a valid url. http://www.website.com/?form=123 on the other hand, is. Quote Link to comment Share on other sites More sharing options...
rfeio Posted August 21, 2008 Author Share Posted August 21, 2008 I'm sorry, I've forgot to include the file name in the links; it should be: http://www.website.com/test.php?form=123 http://www.website.com/test.php/?form=123 Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 So, can you post your actual code? Quote Link to comment Share on other sites More sharing options...
rfeio Posted August 21, 2008 Author Share Posted August 21, 2008 Here's the code: /* Note: $picture value is calculated before and assumes a numeric value */ $url = "http://www.sanzanne.com/showpicture.php"; $redirect = $url.'?picture='.$picture; header("Location: $redirect"); die; If I do an "echo $redirect;" the result is: http://www.sanzanne.com/showpicture.php?picture=19 However, when the header comes in to play the result is: http://www.sanzanne.com/showpicture.php/?picture=19 As you can see instead of having a simple ? I'm getting a /? This means that the picture parameter is ignored and no value is passed to the page showpicture.php. How can I solve this? Cheers! Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 21, 2008 Share Posted August 21, 2008 Try $redirect = $url.'%3Fpicture='.$picture; [edit] Nah...I don't think it will work after all... :-\ Quote Link to comment Share on other sites More sharing options...
rfeio Posted August 22, 2008 Author Share Posted August 22, 2008 I found the problem. On my tests to try to identify the problem, I was passing the correct url to $url and afterwards I was echoing it. I never did test the header this way. For the header I only tested it with MySQL and that was the problem. The MySQL table field that $url was picking its value from had no domain indication So istead of $url having "http://www.sanzanne.com/showpicture.php" it only had "http://showpicture.php". So when I tried to redirect using the header function, the function interpreted "showpicture.php" as being the domain, and therefore had to add the / before the ? causing: http://showpicture.php/?picture=19 when giving the correct value to the table field it worked as expected; the end result was: http://www.sanzanne.com/showpicture.php?picture=19 I feel so stupid! :-) Thanks for all the help guys! Quote Link to comment 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.