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

Link to comment
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
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
Share on other sites

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.