vCard Generator

vCard QR Code Generator












// Include the library
require_once ‘https://claybag.com/QR_Source/phpqrcode/qrlib.php’;

// Check if the form was submitted
if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {
// Get the user inputs
$firstName = $_POST[‘firstName’];
$lastName = $_POST[‘lastName’];
$mobile = $_POST[‘mobile’];
$phone = $_POST[‘phone’];
$fax = $_POST[‘fax’];
$email = $_POST[’email’];
$company = $_POST[‘company’];
$job = $_POST[‘job’];
$street = $_POST[‘street’];
$city = $_POST[‘city’];
$pin = $_POST[‘pin’];

// Create the vCard string
$vCard = “BEGIN:VCARD\n”;
$vCard .= “VERSION:3.0\n”;
$vCard .= “N:” . $lastName . “;” . $firstName . “;;;\n”;
$vCard .= “FN:” . $firstName . ” ” . $lastName . “\n”;
$vCard .= “TEL;TYPE=CELL:” . $mobile . “\n”;
$vCard .= “TEL;TYPE=WORK:” . $phone . “\n”;
$vCard .= “TEL;TYPE=FAX:” . $fax . “\n”;
$vCard .= “EMAIL;TYPE=INTERNET:” . $email . “\n”;
$vCard .= “ORG:” . $company . “\n”;
$vCard .= “TITLE:” . $job . “\n”;
$vCard .= “ADR;TYPE=WORK:;;” . $street . “;” . $city . “;;” . $pin . “\n”;
$vCard .= “END:VCARD”;

// Generate a unique filename for the QR code image
$filename = uniqid() . ‘.png’;

// Generate the QR code image
QRcode::png($vCard, $filename, QR_ECLEVEL_L, 10);

// Output the image tag with the QR code
echo ‘vCard QR Code‘;
echo ‘Download vCard QR Code‘;
}
?>