1

this is my code:

header("Location: ?pid='".$_GET['pid']."'");
die();

When I write a simple echo $_GET['pid']; the value is good but then when I introduce this variable in the header it return something like 27%27 and thats not true true value

When I use urlencode the probleme persist:

header("Location: ?pid=". urlencode($_GET['pid']);

Whats the problem here?

Thank you

5
  • WHAT'S THE ACTUAL VALUE OF $_GET['pid']? CAN YOU PLEASE TELL? Commented Mar 12, 2016 at 21:30
  • Yes te value is a number 540 for example Commented Mar 12, 2016 at 21:31
  • 3
    Your problem are single quotes, try redirecting without them: header("Location: ?pid=".$_GET['pid']); Commented Mar 12, 2016 at 21:31
  • @Nordenheim nop dosent work Commented Mar 12, 2016 at 21:33
  • @BorisDetry I hope you got the solution. Commented Mar 12, 2016 at 21:45

1 Answer 1

2

This is because the parameter is being encoded into URL format. Read about urldecode() PHP function.

Also, the %27 is a URL encoded single quote char, therefore you need to remove single quotes from your code:

header("Location: ?pid=".$_GET['pid']);

If you still however will get %27 in your header, then I would suggest stripping it out from var by using trim() like this:

header("Location: ?pid=".trim($_GET['pid'], "'"));
Sign up to request clarification or add additional context in comments.

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.