QR code in PHP
Hello everyone and welcome to my new article on how to generate qr code in easy way in php. This post is 100% easiest. everywhere you search for done this but you may saw that the uses so many API or plugins for making this.
But, this process is the most easiest and no API or plugins need to make this. So let’s check it out how I made in two simple steps:-
Check out video tutorial of this post just below of this post
Step 1:
First of all you will be need 2 pages/files
- index.php (to make the textbox or where you input anything to generate qr)
- and generator.php (this page is main here has the magic)
Now look at my index.php code:
<!DOCTYPE html> <html> <head> <title>Qr code</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <textarea onkeyup="generate_qrcode(this.value)" cols="50" rows="5"></textarea> <div id="result"></div> </body> <script> function generate_qrcode(sample){ $.ajax({ type: 'post', url: 'generator.php', data : {sample:sample}, success: function(code){ $('#result').html(code); } }); } </script> </html>
You see I have make a textarea and set an event named onkeyup=”generate_qrcode()” and pases the value of the textarea by parameter and make that function in the script and there set a ajax and action is generator.php. Now take a look on generator.php in next step.
Step 2:
Here in generator.php page I have write a simple code. Take a look,I hope no need to discuss briefly this step? Alright.
<?php $code = '<center><img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl='.$_REQUEST['sample'].'" title="Link to Google.com"></center>'; echo $code; ?>
If it helpful then please subscribe for more updates. Comment your interesting point. You can ask me your problems.
Thanks for visiting our blog. Follow our blog site because we have more jQuery Tutorial and we have more tutorial related different type of programming language. You will be happy to know that the DataInFlow is a platform, where you can get the text tutorial and video tutorial of a different kind of programming language like PHP, HTML, Javascript, Jquery, CSS3 and get some more programming tutorial.
thanks, its very helpful for me.
very good. I wish you had given something to save the picture.
do you know how to save the QR code?
I really like what you guys are usually up too.
Such clever work and exposure! Keep up the terrific works guys I’ve incorporated you guys to blogroll.
This the easiest one I have seen.
Only issue is, when I create a new line, the new line is not shown when scanned. All lines end up on one line. I saw textarea used and was expecting the textarea to display exactly as it was input. Any help much appreciated.