Problems sending data via _GET

0

I'm facing a basic language problem (as I see it), and I can not solve it. I have a form and I'm getting the form data via Jquery and throwing it to a file to mount a PDF. But this data is being sent via $ _GET.

But one of the fields is text, and I noticed a situation where if the user places the '&' character, the text is lost, due to the way the data is sent.

I know I could resolve sending data via POST, however I can not submit the form.

    
asked by anonymous 09.04.2014 / 17:05

4 answers

3

If you are using jquery to submit the form try sending it this way:

$('form').serialize();
    
09.04.2014 / 17:24
0

There is a function in PHP that encodes the special characters in URLs, which is called urlencode . And to decode the urldecode is used.

    
09.04.2014 / 17:21
0

If you are generating the url via jquery, you can use encodeURIComponent to get the values typed in the fields, it encodes the special characters.

link

JSFiddle Example

    
09.04.2014 / 20:04
0

You can encode the text in Base64 .

PHP

In PHP you can use the php_encode() and php_decode() functions to encode and decode, respectively.

View the documentation .

Javascript

In Javascript there are already the functions btoa() and atob() , which encode and decode, respectively.

View the documentation .

See an example .

The idea is your code via Javascript to send via GET to the server; and on the server you decode before saving to the database (or whatever you do with that data).

    
11.04.2014 / 15:45