-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding the PHP files for live testing
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>QR Code Generator</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
text-align: center; | ||
padding: 20px; | ||
} | ||
input[type="text"] { | ||
padding: 5px; | ||
font-size: 16px; | ||
width: 300px; | ||
} | ||
button { | ||
padding: 5px 10px; | ||
font-size: 16px; | ||
} | ||
img { | ||
max-width: 300px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>QR Code Generator</h1> | ||
<form method="get" action="qr-generator.php"> | ||
<label for="url">Enter a URL:</label> | ||
<input type="text" id="url" name="url" placeholder="https://www.example.com"> | ||
<button type="submit">Generate QR Code</button> | ||
</form> | ||
|
||
<?php | ||
if (isset($_GET['url'])) { | ||
$url = $_GET['url']; | ||
echo "<img src=\"qr-generator.php?url=$url\" alt=\"QR Code\">"; | ||
} | ||
?> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
require 'vendor/autoload.php'; | ||
|
||
use Endroid\QrCode\Color\Color; | ||
use Endroid\QrCode\Encoding\Encoding; | ||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow; | ||
use Endroid\QrCode\QrCode; | ||
use Endroid\QrCode\Label\Label; | ||
use Endroid\QrCode\Logo\Logo; | ||
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin; | ||
use Endroid\QrCode\Writer\PngWriter; | ||
|
||
// Get the URL from the user input (you can replace this with your own method of obtaining the URL) | ||
$url = isset($_GET['url']) ? $_GET['url'] : 'https://www.example.com'; | ||
|
||
// Create a basic QR code | ||
$qrCode = new QrCode($url); | ||
$writer = new PngWriter(); | ||
|
||
// Customize the QR code | ||
$qrCode | ||
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow()) | ||
->setRoundBlockSizeMode(new RoundBlockSizeModeMargin()) | ||
->setForegroundColor(new Color(0, 0, 0)) | ||
->setBackgroundColor(new Color(255, 255, 255)) | ||
->setLabel('My QR Code') | ||
->setLogoPath(__DIR__ . '/logo.png'); | ||
|
||
// Save the QR code as a PNG image | ||
$result = $writer->write($qrCode); | ||
header('Content-Type: ' . $result->getMimeType()); | ||
echo $result->getString(); |