I am trying to update my codes by saving the data with QR Code.
I tried to implement this tutorial, but It is not saving the QR Code, after I submit the form the page just keeps loading, it only saves the data from the form without the QR Code.
Any help?
this is how I added the udate
include"phpqrcode/qrlib.php";
$folderTemp = 'assets/img/';
$c = $a;
$qrimage = $a.".png";
$qual = 'H';
$ukuran = 6;
$padding = 0;
QRCode :: png($c,$folderTemp.$qrimage,$qual,$ukuran,$padding);
function save_register(){
extract($_POST);
$data = " event_id = '$event_id' ";
$data .= ", name = '$name' ";
$data .= ", address = '$address' ";
$data .= ", email = '$email' ";
$data .= ", contact = '$contact' ";
$data .= ", pacote = '$pacote' ";
$data .= ", qrimage = '$qrimage' ";
if(isset($status))
$data .= ", status = '$status' ";
if(isset($payment_status))
$data .= ", payment_status = '$payment_status' ";
else
$data .= ", payment_status = '0' ";
if(empty($id)){
$save = $this->db->query("INSERT INTO audience set ".$data);
}else{
$save = $this->db->query("UPDATE audience set ".$data." where id=".$id);
}
if($save)
return 1;
}
My Answer:
_once('phpqrcode/qrlib.php');
$data = "Hello, World!";
$filename = "qrcode.png";
$size = 10;
$level = 'H';
$margin = 4;
QRcode::png($data, $filename, $level, $size, $margin);
// Save the data and QR Code to the database
$query = "INSERT INTO table_name (data, qrcode) VALUES ('$data', '$filename')";
// Execute the query
// Display the QR Code
echo "";
Make sure you have the correct path to the phpqrcode library and that the necessary permissions are set for the folder where the QR Code image will be saved. Also, make sure that the data being saved to the database is properly escaped to prevent SQL injection attacks.
Rate this post
3 of 5 based on 3555 votesComments