Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/235303-appending-query-strings/
Share on other sites

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 :)

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.