1

I am looking to generate a QR code on a PHP webpage. The user starts on a page where they submit a form, the only input being the name of the new client. This page is a manager for VPN clients.

After the redirect, PHP generates the configuration file on the page to copy and paste. The user must save this file as wg.conf in their etc directory. I have been trying to use qrencode, a Linux based command line tool to generate the QR code on that same page with the configuration file. According to the documentation on qrencode, you can save the file as a .png or .svg.

I have been playing around with it, both trying to pass data through the URL as GET parameters in the redirect (the only issue is the QR code is sensitive) and by using the backtick operators to run bash commands to save it as a file in the user's local files. I can't seem to figure out where to save it as a file or whether there's another solution to display it on the webpage.

solidforge
  • 36
  • 7

1 Answers1

0

how i would do it:

  1. check this library https://github.com/neocotic/qrious , all you need to do it load the js on your page

  2. generate text you want to convert to qr code in a text area, div or other HTML element and assign it an id

  3. use that id to extract the data via pure JS, now you have a text variable and you have the possibility to make qr code dynamic now

  4. once you have the data dynamically extracted via JS you can use that variable to generate qr codes like this :

var x = 'sample text'
var qr = window.qr = new QRious({
  element: document.getElementById('qrious'),
  size: 200,
  value: x
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
<canvas id="qrious">
Vitalik Jimbei
  • 141
  • 1
  • 9