Drongo_III Posted May 1, 2011 Share Posted May 1, 2011 Hi Guys Again, another noob question that I can't seem to find a concise answer to. What is the best way to append a query string to a url? I've tried using the Header() function but this didn't seem to work - i.e. Header("Location: enc.php?ID=test"); My goal is to change the query string depending on the output of various if else statements. For instance if $test isset then execute some code. The script will be self contained so it'll be posting back to itself with the query string and reacting differently depending on the query string. Any ideas? PS sorry if i am asking too many questions. Eager to learn and struggling to find answers to some things. What I basically want to do (and not sure if this is possible) is to append a different query string based on Quote Link to comment https://forums.phpfreaks.com/topic/235303-appending-query-strings/ Share on other sites More sharing options...
rascle Posted May 1, 2011 Share Posted May 1, 2011 What do you mean you cant append a query string with Header, is this what you mean? <?php if(isset($_GET['hello'])){ $name = $_GET['hello']; echo "Hello ".$name.""; } else{ header("Location: http://www.rasclerhys.com/test6.php?hello=Rhys"); } ?> Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/235303-appending-query-strings/#findComment-1209226 Share on other sites More sharing options...
Pikachu2000 Posted May 1, 2011 Share Posted May 1, 2011 You're going to need to better define "doesn't work". What happens or doesn't happen? Quote Link to comment https://forums.phpfreaks.com/topic/235303-appending-query-strings/#findComment-1209231 Share on other sites More sharing options...
Drongo_III Posted May 2, 2011 Author Share Posted May 2, 2011 Well that seems to work now. I can't work out what was going wrong but I kept getting a message saying it couldn't load the page "because the requested action will never complete". This was a browser generated message. Anyway retried it and it's working fine with header now. I think i'd been staring at the screen too long! Thanks for help chaps! Quote Link to comment https://forums.phpfreaks.com/topic/235303-appending-query-strings/#findComment-1209618 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.