Topic: Special characters being removed from php query links

I have a snippet that displays a list of hyperlinks that contain php queries.

http://mysite.com/mypage?name="smith,john h"&account="abc;123"

When clicked the query received by the page is:

name="smithjohn h"&account="abc123"

Can someone please tell me why the special characters are getting stripped out.

Thanks

Re: Special characters being removed from php query links

Not my strong suit, but I have some thoughts.

I don't see any actual PHP here, so I think we are talking about HTTP query strings.  In a link like this, the browser will make a GET request for a page with the parameters in the query string. I think you have 2 things to consider as options.

1. Make it a form rather than a list of links and use a POST action instead.  Query strings are encoded automatically in a POST request.

2. Build the links in your Snippet or wherever using PHP's urlencode function (see: http://php.net/manual/en/function.urlencode.php )

monstrahost's Website

Re: Special characters being removed from php query links

I will try to figure out PHP's urlencode function. To reproduce what I am currently doing:

Create a Chunk:

Name: $n
"; echo "
Acct: $a
"; ?>

Call that chunk in a template and then assign template to a page:

Browse to the page:

http://mysite/test?name=%22smith%20john%20n%22&acct=%22abc%3B123%22
http://mysite/test?name="smith,john n"&acct="abc;123"

Results are:

Name: smith john n
Acct: abc123

Re: Special characters being removed from php query links

I tried with urlencode and got basically the same result:

Name: $n
"; echo "
Acct: $a
"; ?>

Results:

Name: smithjohn+n
Acct: abc123

Re: Special characters being removed from php query links

Looks like the REQUEST method will work.

Name: $n
"; echo "
Acct: $a
"; ?>

Results:

Name: "smith,john n"
Acct: "abc;123"