4

my question is about the header() function. I'm trying to send 2 variables trough this function like this:

header("Location:index.php?variable_1='true'&variable_2='false'");

I think its the problem in escaping & but i tried it just with &. Also, first variable gets initialized and I can acquire it by calling$_GET['variable_1']` but the second one is none existent and is not initialized.

So my question is, can I send more than one value trough header() function via GET method?

Thank you for your time!

3
  • oh, I apologize. Hello, everyone! Commented Jan 18, 2013 at 7:14
  • 1
    You don't need to do foo='bar'&bar='baz'. Lose the quotes, so foo=bar&bar=baz. They're not needed and will only cause unnecessary complications. Commented Jan 18, 2013 at 7:18
  • if accepted as your answer please mark answer by clicking on tick button below any answer which is your answer Commented Jan 18, 2013 at 9:36

2 Answers 2

5

yes,you can just in case to do that

header("Location: index.php?variable_1=true&variable_2=false");

you dont need to use '' this

Sign up to request clarification or add additional context in comments.

5 Comments

im sorry. i was misunderstood. i can only pass one variable with this call header("Location:index.php?value1=false&value2=true"); The value1 variable is initialized but value2 is not. I cant access it with & or with & but the first one i can.
when you redirected to new address is this the address when yo redirected?please look in address bar index.php?variable_1=true&variable_2=false
now it works. before i posted a question, i tested it the same way and it didn't work. the same code now works. i apologize for wasting everyones time, im an idiot.
great that it works.please accept one answer and press on tick below of answer to accept as your answer and get 2 point
im affraid i dont have enough reputation to do that. i will remember to do that when my reputation rises.
1

Try this:

header("Location:index.php?variable_1=true&variable_2=false");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.