• Techblog369, India
  • June 8, 2023

How To Configure A Sendinblue SMTP Relay in Postfix?

Fix Email Issues in CyberPanel with SMTP Relay Setup Free Method. First Create a email using your Cyberpanel Under Emai Tab Create Email Second go to the SSL tab and click …

Create a simple password strength indicator with JavaScript

You’ve probably seen many examples of password strength indicators around the web. They let users know the password they’re using is weak and indicate how the strength changes when it’s modified. …

Hi In this Article I am going to show how to create QR code and save it to database also fetch QR Code in a Table

Create a Page addqrcode.php in a root directory and paste the below code.

<section class="main--content">
        <div class="row gutter-20">
            <div class="col-md-6 mx-auto">
                <!-- Panel Start -->
                <?php $id=$_GET['apartnerId'];$data=qrCode($id);?>
                <div class="panel">
                    <div class="panel-heading">
                        <h3 class="panel-title">Form</h3>
                    </div>
                    <div id="apartner-form" class="panel-content">
                <form method="POST" action="ajax/qrcode.php" enctype="multipart/form-data">
                <div class="form-group">
                    <legend>Add QrCode</legend>
                   <?php 
                   if(isset($_GET['msg']))
                    {
                        echo $_GET['msg'];
                    }

                   ?>
                </div>
                    <!-- Member ID -->
                    <div class="form-outline">
                        <input type="hidden" class="form-control" id="uid" name="uid"
                            value="<?php echo $data['uid']; ?>" readonly />
                    </div>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="fname" name="fname"
                            value="<?php echo $data['first_name']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="lname" name="lname"
                            value="<?php echo $data['last_name']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="email" name="email"
                            value="<?php echo $data['email']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="bcode" name="bcode"
                            value="<?php echo $data['bcode']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="state" name="state"
                            value="<?php echo $data['sts']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="district" name="district"
                            value="<?php echo $data['district']; ?>" readonly />
                    </div><br>
                    <div class="form-outline">
                        <input type="text" class="form-control" id="city" name="city"
                            value="<?php echo $data['city']; ?>" readonly />
                    </div><br>
                    <!-- Submit button -->
                    <button type="submit" class="btn btn-primary btn-sm mt-3" name="submit">Submit</button>
                </form>
            </div>
                </div>
        </div>
    </section>
    <!-- Main Content End -->

Create a Folder under root directory Connection/Functions.php

Functions.php
<?php
include('DBClass.php');// Database Connection
function qrCode ($id){
    $db= new DBClass();
    $result= $db->query('SELECT * FROM `tbl_accounts` where `uid`= "'.$id.'"');
    return mysqli_fetch_array($result);
}

Create a Folder ajax/qrcode.php and paste the below code

qrcode.php

<?php
include('../libs/phpqrcode/qrlib.php'); 
if(isset($_POST['uid'])){
$path ='../temp/';
$uid=$_POST['uid'];
$time=time();
$file=$uid.$time.".png";
$email= $_POST['email'];
$subject= $_POST['bcode'];
// $fname= $_POST['fname'];
$lname= $_POST['lname'];
$sts= $_POST['sts'];
$district= $_POST['district'];
$city= $_POST['city'];
$body = $_POST['fname'];
$codeContents = 'mailto:'.$email.'?subject='.urlencode($subject).'&body='.urlencode($body);

include('../Connection/Functions.php');
$conn = new DBClass();
// $sql="UPDATE `tbl_accounts` SET `qrcode`="'.$file.'" WHERE `uid`="'.$uid.'"');
$sql="UPDATE tbl_accounts SET `qrcode` = '$file' WHERE `uid` = '$uid'";
if($conn->query($sql)===true){
    QRcode::png($codeContents, $path.''.$file, QR_ECLEVEL_L, 5);
    header('location:../apartnerQrcode?msg= Data added Successfully');
}
else{
    header('location:../apartnerQrcode?msg= Faild!!');
}
}
?>
                                      

Download Php qrcode libery fro github and include it on qrcode.php page

https://github.com/giansalex/phpqrcode/tree/master/src

include(‘../libs/phpqrcode/qrlib.php’);

Create a folder where you want to save the QRcode

$path =’../temp/’;

If you want to full source code you can msg or comment me.

Thanks..

Author

nw.ippm@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *