Merhaba.
Biraz aradan sonra yeni konuyla karşınızdayım.
Bu konuda PHP qrcode kütüphanesi ile QR Code oluşturma scripti kodlayacağız.
Konunun sonuna ekleyeceğim QR CODE'u okutmanız tavsiye edilir
Buyrun Kodlar ;
Biraz aradan sonra yeni konuyla karşınızdayım.
Bu konuda PHP qrcode kütüphanesi ile QR Code oluşturma scripti kodlayacağız.
Konunun sonuna ekleyeceğim QR CODE'u okutmanız tavsiye edilir
Buyrun Kodlar ;
PHP:
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR Kod Oluşturucu</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 min-h-screen">
<div class="container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<div class="bg-gradient-to-r from-blue-500 to-indigo-600 p-6">
<h3 class="text-2xl font-bold text-white text-center">QR Kod Oluşturucu</h3>
</div>
<div class="flex flex-col md:flex-row">
<div class="w-full md:w-1/2 p-6 border-b md:border-b-0 md:border-r border-gray-200">
<form method="post" action="" class="space-y-4">
<div>
<label for="type" class="block text-sm font-medium text-gray-700 mb-2">QR Kod Türü:</label>
<select class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" id="type" name="type">
<option value="text">Metin</option>
<option value="url">Bağlantı</option>
</select>
</div>
<div id="textInput">
<label for="text" class="block text-sm font-medium text-gray-700 mb-2">Metin İçeriği:</label>
<input type="text" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" id="text" name="text">
</div>
<div id="urlInput" class="hidden">
<label for="url" class="block text-sm font-medium text-gray-700 mb-2">Bağlantı:</label>
<input type="url" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" id="url" name="url" placeholder="https://">
</div>
<button type="submit" class="w-full bg-gradient-to-r from-blue-500 to-indigo-600 text-white py-2 px-4 rounded-md hover:from-blue-600 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200">
QR Kod Oluştur
</button>
</form>
</div>
<div class="w-full md:w-1/2 p-6">
<div class="h-full flex items-center justify-center">
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST') {
require 'phpqrcode/qrlib.php';
$tempDir = "qr_codes/";
if (!file_exists($tempDir)) {
mkdir($tempDir);
}
$type = $_POST['type'];
$content = '';
if($type === 'text' && !empty($_POST['text'])) {
$content = $_POST['text'];
} elseif($type === 'url' && !empty($_POST['url'])) {
$content = $_POST['url'];
}
if(!empty($content)) {
$fileName = 'qr_'.md5($content).'.png';
$filePath = $tempDir . $fileName;
QRcode::png($content, $filePath, QR_ECLEVEL_L, 10);
echo '<div class="text-center space-y-4">';
echo '<h4 class="text-xl font-semibold text-gray-800">Oluşturulan QR Kod:</h4>';
echo '<div class="p-4 bg-white rounded-lg shadow-sm inline-block">';
echo '<img src="'.$filePath.'" alt="QR Code" class="mx-auto w-48 h-48">';
echo '</div>';
echo '<div class="space-y-2">';
echo '<a href="'.$filePath.'" download class="inline-block bg-green-500 text-white py-2 px-4 rounded-md hover:bg-green-600 transition-colors duration-200">QR Kodu İndir</a>';
if($type === 'url') {
echo '<p class="mt-2"><a href="'.$content.'" target="_blank" class="inline-block bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 transition-colors duration-200">Bağlantıyı Aç</a></p>';
}
echo '</div>';
echo '</div>';
} else {
echo '<div class="text-center text-gray-500">';
echo '<p>QR kod oluşturmak için bilgileri giriniz</p>';
echo '</div>';
}
} else {
echo '<div class="text-center text-gray-500">';
echo '<p>QR kod oluşturmak için bilgileri giriniz</p>';
echo '</div>';
}
?>
</div>
</div>
</div>
</div>
<!-- RICARDIE -->
<div class="mt-6 text-center">
<p class="text-gray-500 text-sm">
Developer: <span class="font-semibold text-indigo-600">ricardie</span>
</p>
</div>
</div>
</div>
<script>
document.getElementById('type').addEventListener('change', function() {
const textInput = document.getElementById('textInput');
const urlInput = document.getElementById('urlInput');
if(this.value === 'text') {
textInput.classList.remove('hidden');
urlInput.classList.add('hidden');
document.getElementById('url').removeAttribute('required');
document.getElementById('text').setAttribute('required', '');
} else {
textInput.classList.add('hidden');
urlInput.classList.remove('hidden');
document.getElementById('text').removeAttribute('required');
document.getElementById('url').setAttribute('required', '');
}
});
</script>
</body>
</html>

