Problems sending data via _GET

Asked

Viewed 410 times

0

I am facing a basic language problem (in my view), and I am not being able to solve it. I have a form and am taking the form data via Jquery and playing to a file to assemble a PDF. But this data is being sent via $_GET.

However one of the fields is text, and I noticed a situation where if the user puts the character '&', the text is lost, due to the way of sending this data.

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

  • You are mounting the URL in hand when submitting... normally the content of the text field is encoded appropriately, even if it contains the character &?

  • The value of & is coded as %26 by browser.

  • Enter the code you call the form and also the PDF.

  • As you are using Jquery, make by serialize(), that it will automatically propose the conversion of & for %26

  • Where the user passes the jquery date parameter use the $("#idform"). serialize();

4 answers

3

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

$('form').serialize();
  • does not work, even so there is the division of information.

0

You can encode the text in Base64.

PHP

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

View documentation.

Javascript

Already in Javascript there are functions btoa() and atob(), coding and decoding respectively.

View documentation.

Take an example.


The idea is to encode via Javascript to send via GET to the server; and on the server you decode before saving to the bank (or whatever you do with this data).

0

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

  • but I am not using PHP to generate the URL, I am creating the link at hand, via Jquery.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.