instascan
instascan copied to clipboard
how to get the scanned content to php script
is there any way to get the scanned qr code value to php script
Yes! After several hours of work I finally succed! You just have to use a hidden text:
<transition-group name="scans" tag="ul">
<li v-for="scan in scans" :key="scan.date" :title="scan.content">{{ scan.content }}
<form action="target.php" method="get">
<input type="hidden" name="qr" :key="scan.date" :value="scan.content" />
<input type="submit" value="Send to PHP"/>
</form>
</li>
</transition-group>
This will create a button submit into your html that will send it to your php (target.php) and with:
$_GET['qr']
you can recuperate the value
Hi,
Thanks for your valuable time. But with this we get the value only when we click on the button.. But What I am asking is when scanning a qr code it automatically get the content to php script. Actually I need to create a login page with QR Code scanning. And when I added the hidden text with the code the camera function not working
On Fri, Jun 15, 2018 at 2:37 PM, Timy [email protected] wrote:
Yes! After several hours of work I finally succed! You just have to use a hidden text:
{{ scan.content }} This will create a button submit into your html that will send it to your php (target.php) and with: $_GET['qr'] you can recuperate the value
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/schmich/instascan/issues/155#issuecomment-397561135, or mute the thread https://github.com/notifications/unsubscribe-auth/AcX0culxsaCoZoBWce3H13e1OxZEPoxgks5t83lYgaJpZM4UkNsS .
@krishnapreejith try using an automated submission of form through javascript.
you can look at this to start with.
document.getElementById("myForm").submit();
make sure inputs inside your form are all hidden.
<input type="hidden" />
I have also tried this approach to no avail, this is my html:
<div class="col-md-6">
<div class="card">
<div class="header">
<h4 class="title">Guest Check In</h4>
<p class="category">Scan guests in below</p>
<div id="app">
<div class="preview-container">
<video id="preview" width="250" height="250"></video>
<section class="scans">
<ul v-if="scans.length === 0">
<li class="empty">No scans yet</li>
</ul>
</div>
<transition-group name="scans" tag="ul" class="unstyled">
<h3 v-for="scan in scans" class="unstyled" :key="scan.date" :title="scan.content">{{ scan.content }}
<form name="checkinguest" action="checkinguest.php" method="POST">
<input type="hidden" name="LogID" :key="scan.date" :value="scan.content" />
<input type="submit" name="qrcode" class="btn btn-success" value="Check In" />
</form>
</h3>
</transition-group>
</section>
</div>
</div>
</div>
</div>
And this is the javascript:
'<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
scanner: null,
activeCameraId: 1,
cameras: [],
scans: []
},
mounted: function () {
var self = this;
self.scanner = new Instascan.Scanner({ video: document.getElementById('preview'), scanPeriod: 1, mirror: false});
self.scanner.addListener('scan', function (content, image) {
self.scans.unshift({ date: +(Date.now()), content: content });
var audio = new Audio('beep.mp3');
audio.play();
document.getElementById("qrcode").click();
});
Instascan.Camera.getCameras().then(function (cameras) {
self.cameras = cameras;
if (cameras.length > 0) {
self.activeCameraId = cameras[1].id;
self.scanner.start(cameras[1]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
console.error(e);
});
},
methods: {
formatName: function (name) {
return name || '(unknown)';
},
selectCamera: function (camera) {
this.activeCameraId = camera.id;
this.scanner.start(camera);
}
}
});</script>'
Yes! After several hours of work I finally succed! You just have to use a hidden text:
<transition-group name="scans" tag="ul"> <li v-for="scan in scans" :key="scan.date" :title="scan.content">{{ scan.content }} <form action="target.php" method="get"> <input type="hidden" name="qr" :key="scan.date" :value="scan.content" /> <input type="submit" value="Send to PHP"/> </form> </li> </transition-group>
This will create a button submit into your html that will send it to your php (target.php) and with:
$_GET['qr']
you can recuperate the value
Hello, I'm adding this but the qr code is not being sent to target.php. My code is: * * *
<div id="scanner">
<video id="preview"></video>
<transition-group name="scans" tag="ul">
<li v-for="scan in scans" :key="scan.date" :title="scan.content">{{ scan.content }}
<form action="target.php" method="get">
<input type="hidden" name="qr" :key="scan.date" :value="scan.content" />
<input type="submit" value="Capture" class="btn mt-4"/>
</form>
</li>
</transition-group>
</div>