Jump to content

[SOLVED] urldecode


jaymc

Recommended Posts

basic example

 

<?php
$data = "JMC & U.K Soulja";
echo urldecode($_GET['NewData']);
?>
<a href="?NewData=<?php echo urlencode($data);?>">test</a>

 

 

try this on a new php file.

Yes thats working fine, but that not the problem

 

The problem is I am using $_GET to retrieve info from that URL, however when its been decoded the name is not coming out as JMC & U.K Soulja its coming out as it is decoded

 

So, I need a way to convert a decoded URL into an UNECODED one

 

Before = JMC+%26+U.K+Soulja

After = JMC & U.K Soulja

 

Ive also tried rawurldecode

Link to comment
https://forums.phpfreaks.com/topic/65268-solved-urldecode/#findComment-325928
Share on other sites

really you should fix the sending process but

 

heres an idea..

 

<?php
echo "test2<br /><br />";
$data = "JMC & U.K Soulja";

$test = urldecode($_SERVER['QUERY_STRING']);
if (preg_match('/=(.*)/i', $test, $regs)) {
$result = $regs[1];
}
echo $result;	

?>

<a href="?newdata=<?php echo $data;?>">test</a>

Link to comment
https://forums.phpfreaks.com/topic/65268-solved-urldecode/#findComment-325935
Share on other sites

Oh, it is because the $_GET array is only holding JMC. When you pass a value by GET like that, it delimits by whitespaces so your php file is only receiving up to the first space. I think you are going to have to correct the way it sends the data.

Thats not the case

 

I used rawurlencode to make the URL safe, then strangely enough just echoing the $_GET works

 

I think php is decoding it for me automatically..

 

Anyway, solved. Thanks for input guys

Link to comment
https://forums.phpfreaks.com/topic/65268-solved-urldecode/#findComment-325940
Share on other sites

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.