Current Path :
/
home
/
zrcdevco
/
www
/
QR-Code
/
qr-urls
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/zrcdevco/www/QR-Code/qr-urls/qr-encode-input.php
<?php // // Update to take in two parameters - URL and Image name // from a form and then output the image to the screen as a result. include('phpqrcode/qrlib.php'); function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // define variables and set to empty values $url_value = $image_name = ""; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (empty($_GET["url_value"])) { $url_value_err = "URL is required"; } else { $url_value = test_input($_GET["url_value"]); if (!preg_match("/\b(?:(?:https?):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url_value)) { $url_value_err = "Invalid URL"; } } if (empty($_GET["image_name"])) { // no image_name provided, use default $image_name = "qr_image.png"; } else { $image_name = test_input($_GET["image_name"]); } // outputs image directly into browser, as PNG stream QRcode::png($url_value,$image_name,QR_ECLEVEL_L,7); ?> <img src="<?php echo $image_name;?>" alt="QR Code for URL - <?php echo $url_value;?>"> <?php } else { ?> <html> <body> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="GET"> URL: <input type="text" name="url_value" value="<?php echo $url_value;?>"> <span class="error">* <?php echo $url_value_err;?></span> <br> Image Name: <input type="text" name="image_name" value="<?php echo $image_name;?>"><br> <input type="submit"> </form> </body> </html> <?php }