ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Generate QR code image and pass it to view

September 22, 2013 9:22am

Subscribe [2]
  • #1 / Sep 22, 2013 9:22am

    Fyodor

    4 posts

    Hello
    I am trying to generate QR code image in PHP and pass it to view. Is it possible?
    E.g.:
    I call php function through ajax:

    url: base_url+"ajax_controller/"+phpMethodName,
         type: 'GET',
         dataType: 'json',
         data:{
          'meetingID':$('#meeting_ID').val(),
          'userID':$('#user_ID').val()      
         },

    phpMethodName is

    <?php
    public function newParticipation(){
        $data=$this->input->get();
        //firstly check if user has been participated already
        if($this->meetings_model->checkParticipation($data['meetingID'], $data['userID'])==true){
         $result=false;
        }
        else{
         $result=array();
         //insert new entry into participant DB table
         $this->meetings_model->addParticipation($data['meetingID'], $data['userID']);
         
         //generate QR code------------------- 
         $this->load->library('ciqrcode');
         $params['data']="somestring" //this is a string for QRcode
         //$qrimage=$this->ciqrcode->generate($params);
    
         // check again: data shoud be inserted in DB
         if($this->meetings_model->checkParticipation($data['meetingID'], $data['userID'])==true){
          $result['inserted']=true;
          $result['image']="";
         }
        }
        echo json_encode($result);
       
    } //end function new participation

    I used qr code library from this link https://github.com/dwisetiyadi/CodeIgniter-PHP-QR-Code
    My idea was to write qrcode image into $result[‘image’] and pass it to view through ajax. But something is wrong, I am not able to write image into $result…


    I don’t want to create new file and save it on my server for each qr code generation.
    Is it possible to generate qr code image on fly and use this image in my view after?

    Or may be the best way is generate QR code image using jquery plugins, not on server side?

    regards,
    Fyodor

     

  • #2 / Nov 25, 2013 9:25pm

    makaveiljojo

    1 posts

    Hello Fyodor,
    It is absolutely yes you can generate QR code image in PHP and pass it to view. Here is a PHP Barcode Generator Script Tutorial which might be helpful. The PHP Barcode Generator is a server-side script that adds barcode generation capability to any PHP-compatible website. And I’m not sure if it is the best way to generate QR code using jquery plugins or on server side.You may try and choose the one suits you most.

    Best,
    Makaveil

  • #3 / Nov 27, 2013 1:38pm

    Fyodor

    4 posts

    Hi Makaveil,

    thank you for link, it will be helpful for me

    regards,
    Fyodor

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases