In this tutorial, we will learn how to create a dynamic QR Code generator for a business vCard with an admin panel in PHP. A business vCard (Virtual Card) is used to show business-related details like name, designation, bio, company, phone number, WhatsApp, website, etc.
Anyone can scan the QR code to check the live digital business card. In the current digital era, the demand for digital business cards is increasing day by day. In this system, we will learn the complete database structure and coding required for users to create a card (vCard) and manage it from the admin dashboard. We will create a smart structure for both the QR code and the card. As you know, many QR code systems save data directly into the QR code itself, but there is an issue with that approach: you cannot update the data after downloading it. To solve this, we will create a system that allows you to update the card information at any time. You won’t need to update the QR code; you can use the same downloaded QR code to check the updated file. Just scan the QR code and see the live card.
In this tutorial, we will use Bootstrap to create a responsive admin panel and business card (vCard), since most users scan and open the card link on mobile devices. The card's design will have a professional look and feel.
Let’s create a dynamic QR Code generator for a card in PHP –
1. Create database tables –
First, we will create database tables for the admin users and the vCards:
users
CREATE TABLE `users` (
`uid` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fname` varchar(100) DEFAULT NULL,
`username` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`udate` datetime DEFAULT NULL
);
vcard
<code class="language-php">
CREATE TABLE `vcard` (
`vid` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`image` varchar(255) DEFAULT NULL,
`fname` varchar(50) DEFAULT NULL,
`designation` varchar(255) DEFAULT NULL,
`company_name` varchar(255) DEFAULT NULL,
`short_bio` varchar(355) DEFAULT NULL,
`slug` varchar(355) DEFAULT NULL,
`phone_number` varchar(20) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`whatsapp` varchar(20) DEFAULT NULL,
`website` varchar(100) DEFAULT NULL,
`views` int(11) DEFAULT 0,
`created_at` datetime DEFAULT NULL
) ;</code></pre>
The users table will be used to create and save admin user data, such as name, email, username, and password. The vCard table is the most important table, as it will be used to generate the business card with business-related details like name, designation, bio, company, phone number, WhatsApp, website, etc.
2. PHP database Connection file –
The connection file is used to connect the PHP page to the MySQL database. In this project, we will use PHP PDO (PHP Data Objects) with prepared statements because it is highly secure and protects your application against SQL injection.
config.php
Define your host, database name, database user, and password. If you are using XAMPP or WAMP, use these details:
host: localhost
dbname: [your created database name]
dbuser: root
dbpass: [leave empty / no password]
3. Login process for vCard Admin panel –
As we already discussed above, we will create an admin panel for this business card project. The login form will be used to access the control panel (admin panel). From there, the admin can easily log in and manage the vCard data records.
Create an admin folder, and inside it, create a login.php file.
admin/login.php
As you can see in the above code, we stored the user ID and full name (fname) in different session variables. This allows us to use them on any page of the admin panel to display the user's full name and fetch data from the database users table using the user ID.
4. Business Card Admin Panel dashboard –
An admin panel is essential for every PHP project, providing a secure place from which the admin can control the complete data record. The admin can create new admin users and generate QR codes for digital business cards (vCards). From this control panel, the admin can also easily create, update, and delete business cards. The admin can update card details without changing the QR code because the QR code remains the same; it is created only once, meaning there is no need to update the QR code when updating business card information.
Let’s create the admin panel dashboard home page and its supporting files:
index.php
header.php
footer.php
We will also need the admin logout process PHP file:
logout.php
On this admin dashboard, we display the total count of users and the total count of vCards. There is a sidebar, a footer, and a header that includes an avatar image and a logout feature.
5. Admin user management in Admin Panel –
To keep the system secure from unknown users, the admin can add, update, and delete users. In a previous tutorial, we created an admin panel with multi-role features. You can check it out here:
Create a Certificate Generator with QR Code Verification & Admin Panel in PHP
Let’s create user management:
admin/users.php
6. Generate QR code & business vCard Management –
This is the main part of the admin control panel. The admin can manage and supervise all digital cards and QR codes using this feature.
Here is the QR code and business card management workflow:
QR Code Control: The admin can generate and download a new QR code for a business card or edit and delete that business card's details if needed.
Tracking: The admin can check the live view count on the card to see how many times it has been opened and scanned.
admin/vcards.php
7. phpqrcode library installation –
To generate a QR code, we can use multiple methods. For example, you can use the QR Server API, which we used in our previous tutorial, but in this tutorial, we will use a standard method: the phpqrcode library.
Go to the
PHPQRCode GitHub repository
And download the ZIP file. Extract the ZIP file inside your admin folder. Make sure the folder name is exactly phpqrcode. If the extracted folder has a different name, like phpqrcode-master, rename it to phpqrcode and move it inside the admin folder.
Now, create a QR code support file. In this PHP file, we will include the phpqrcode library and use the png() function to generate a QR code PNG file. You can easily download this business card QR code and use it anywhere.
qrcode.php
The $text variable will be used to embed the business card link into the QR code.
Now, run the vcards.php file from the admin panel and generate a new QR code for your business card.
8. Digital business card public page –
Our digital business card public page is a modern and highly responsive profile solution that makes networking effortless. When a user scans the QR code, they are redirected to a mobile-friendly landing page for the card. On this page, your professional contact details, name, social media links, and portfolio are displayed in an organized manner. Any visitor can easily save your contact details directly to their mobile phone by downloading a VCF file using the "Save Contact" button.
Create a vcard.php file in the root folder (not in the admin folder):
vcard.php
To make SEO-friendly URLs, we can use an .htaccess file. Create a .htaccess file in the same root folder and use the code below:
.htaccess
9. Download business card contact details in VCF format –
Here is the corrected version of your final section, fixing the typos, grammar, and sentence transitions while keeping your original tone:
When a user clicks on the "Save Contact" button, they will need a VCF downloader file. This PHP file code handles downloading the contact in VCF format and saving it directly into your mobile or computer contacts.
download_vcard.php
Any public visitor can save your contact details in VCF format simply by clicking the "Add Contact" button on your digital business card.
And that’s it! Now you can easily build your own dynamic QR code generator for digital business cards using PHP and MySQL with a full admin dashboard.