A simple PHP script using the library phpqrcode for the generation of QR codes
Link to the programme:
https://wiki.ostrowski.net.pl/qrcode/
To generate a QR code for the wifi network, simply edit and paste this text into the generator:
WIFI:T:<encryption>;S:<SSID>;P:<password>;H:<hidden>;;
Explanation:
T: Encryption type (WPA, WPA2, WPA3, WEP, or nopass for open networks).S: SSID (WiFi network name)P: PasswordH: SSID hidden (true false)Example:
WIFI:T:WPA;S:quest-network;P:pass1234;;
Solution code:
<?php require_once './phpqrcode/qrlib.php'; // include the QR library ?> <!DOCTYPE html> <html> <head> <title>Simple QR Code Generator</title> </head> <body> <h2>QR Code Generator</h2> <form method="post"> Enter text or URL: <input type="text" name="text" required style="width: 400px;"> <button type="submit">Generate QR Code</button> </form> <p>if you want wifi qrcode then edit and paste this: <tt>WIFI:T:WPA;S:quest-network;P:pass1234;;</tt></p> <?php if (!empty($_POST['text'])) { $text = $_POST['text']; $filename = 'qrcode.png'; // Dynamically adjust the size based on the length of the input text $dataLength = strlen($text); $size = 5; // Default size if ($dataLength <= 50) { $size = 5; // Small amount of data } elseif ($dataLength <= 100) { $size = 6; // Medium amount of data } elseif ($dataLength <= 200) { $size = 7; // Larger data } elseif ($dataLength <= 300) { $size = 8; // Even larger data } else { $size = 9; // Very large data } // Create the QR code with the calculated size QRcode::png($text, $filename, QR_ECLEVEL_L, $size); echo "<h3>Your QR Code:</h3>"; echo "<img src='$filename'><br>"; echo "<a href='$filename' download>Download QR Code</a>"; } ?> </body> </html>