After receiving the data sent from the client, add the data as a parameter to the URL and generate the QR code for the URL. The QR code can be generated, but the URL of the generated QR code does not contain the parameters I want. The code is as follows {code ...} it is estimated that there is a problem when the parameter data transmission comes over, but I don't know how to arrange it... after receiving the data sent from the client, add the data as a parameter to the URL and generate the QR code for the URL. The QR code can be generated, but the URL of the generated QR code does not contain the parameters I want.
The code is as follows:
$ Param_str = urldecode ($ _ POST ['data']); $ param_str = base64_encode ($ param_str); $ url = "http://www.example/order_add.php? Data = ". $ param_str; // url1 is to write parameters directly into the URl // $ url1 =" http://www.example/order_add.php? Data = blank = "; // The data parameter in the link for generating the QR code is empty echo QRcode: png ($ url ); // This generates the correct QR code // echo QRcode: png ($ url1); // $ url is 1 compared with $ url1 constant, and both are encoded in ASCII format.
It is generally estimated that there is a problem when data transmission comes over, but I don't know how to troubleshoot it.
In addition, the correct QR code can be generated.
// Manually assign $ param_str = "required Sources = "; $ url =" http://www.example/order_add.php? Data = ". $ param_str; echo QRcode: png ($ url); // add a path to generate an object image file. if multiple users access the file at the same time, the former will be overwritten. Therefore, it is not suitable for actual use of QRcode: png ($ url, "order_qr.png ");*/
Reply content:
After receiving the data sent from the client, add the data as a parameter to the URL and generate the QR code for the URL. The QR code can be generated, but the URL of the generated QR code does not contain the parameters I want.
The code is as follows:
$ Param_str = urldecode ($ _ POST ['data']); $ param_str = base64_encode ($ param_str); $ url = "http://www.example/order_add.php? Data = ". $ param_str; // url1 is to write parameters directly into the URl // $ url1 =" http://www.example/order_add.php? Data = blank = "; // The data parameter in the link for generating the QR code is empty echo QRcode: png ($ url ); // This generates the correct QR code // echo QRcode: png ($ url1); // $ url is 1 compared with $ url1 constant, and both are encoded in ASCII format.
It is generally estimated that there is a problem when data transmission comes over, but I don't know how to troubleshoot it.
In addition, the correct QR code can be generated.
// Manually assign $ param_str = "required Sources = "; $ url =" http://www.example/order_add.php? Data = ". $ param_str; echo QRcode: png ($ url); // add a path to generate an object image file. if multiple users access the file at the same time, the former will be overwritten. Therefore, it is not suitable for actual use of QRcode: png ($ url, "order_qr.png ");*/
I answered the question by myself. I only found the error and did not find the cause.
This problem occurs when the client uses JQuery $. the parameters passed by ajax make phpqrcode unable to be obtained (data is indeed obtained on the server side, and the url of phpqrcode is correct before encoding ), the client can use form submission instead.
Urldecode is not required for jquery ajax operations. In fact, urlencode is generally used, and the browser automatically decode.
Check whether the parameter is missing due to this reason.