Jump to content

encoding a URL and using in a header


takn25

Recommended Posts

Hi, i would like to encode a url example.

 

$error="You must be signed in";
$enc=urlencode("http://localhost/finxed/asku/asked.php?error=$error");
header("LOCATION: $enc");

 

Could some one tell me what can i do to achieve my desired result. I want the header to take to the LOCATION, which is $enc but i wanted it to be encoded when displayed in the url field. The current code is not working.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/227007-encoding-a-url-and-using-in-a-header/
Share on other sites

The only thing you would likely need to use urlencode() on would be the $error variable. Give this a try.

 

$enc=urlencode($error);
header("Location: http://localhost/finxed/asku/asked.php?error=$enc");

Archived

This topic is now archived and is closed to further replies.

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