Jump to content

rawurlencode()


Love2c0de

Recommended Posts

Hi guys and girls, I'm passing some data through the url such as the name of a game to be used later in a query. Not highly sensitive but I wanted to rawurlencode it.

 

Can't seem to ever be able to use functions within urls.

 

Here is what I've got:

<?php if(isset($_SESSION['username'])) {
/*
echo "<div id='home_link_div'>";
echo "<a href='?page=home'>ALL</a>";
*/

echo "<a href='?page=home&g=",rawurlencode("Battlefield 3"),"'>BF3</a>";

/*
echo "<a href='?page=home&g=Counter-Strike 1.6'>CS 1.6</a>";
echo "<a href='?page=home&g=Counter-Strike: Source'>CS:S</a>";
echo "<a href='?page=home&g=Deus Ex'>DX</a>";
echo "<a href='?page=home&g=Left 4 Dead 2'>L4D2</a>";
echo "<a href='?page=home&g=Call Of Duty: Modern Warfare 4'>MW3</a>";
echo "</div>";
*/
}
?>

 

Im just trying to get the first one to work then I can apply that to the others. I have commented the others out and spaced them down for readability.

 

Thank you for any help you can give me.

 

Kind regards,

 

L2c.

Edited by Love2c0de
Link to comment
Share on other sites

Not highly sensitive but I wanted to rawurlencode it.

 

rawurlencode isn't there for protecting sensitive data, it's there because some characters are invalid in a URL and therefore have to be encoded.  For example a space character needs to be encoded as either + or %20.

 

 

echo "<a href='?page=home&g=",rawurlencode("Battlefield 3"),"'>BF3</a>";

 

That code works fine, and outputs:

<a href='?page=home&g=Battlefield%203'>BF3</a>

 

If your expecting something else you'll have to clarify what it is you are expecting. 

 

 

@Jessica  echo actually accepts multiple arguments so doing echo $a, $b, $c is essentially the same as echo $a.$b.$c; but saves having to perform the concatenation step. 

 

Link to comment
Share on other sites

  • 2 weeks later...

Do I have to hardcode the spaces for example Deus%20Ex when passing the value through the URL?

 

My colons appear to encode in the URL bar when using urlencode() but the spaces don't. I've seen on websites where you see the url encoded in the url bar and not just the source.

 

Is there some kind of directive I need to change in php.ini?

 

I've tried urlencode too but doesn't seem to encode anything but colons.

 

Sorry disregard that whole post^^

 

Regards,

 

L2c.

Edited by Love2c0de
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.