I have this PHP code that creates a QR code with the given data:
<?php
include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php');
$tempDir = JPATH_SITE . '/images/';
$codeContents = 'This Goes From File';
$fileName = 'qr_'.md5($codeContents).'.png';
$pngAbsoluteFilePath = $tempDir.$fileName;
$urlRelativeFilePath = JUri::root() .'images/' . $fileName;
if (!file_exists($pngAbsoluteFilePath)) {
QRcode::png($codeContents, $pngAbsoluteFilePath);
}
else {
echo "Not working!";
}
echo '<img src="'.$urlRelativeFilePath.'" />';
?>
What we need is to connect to a MySQL table (#__rsforms_submissions), retrieve some fields (for example, Name and Mail, Phone) and insert them in the QR code instead of the data provided by the example. To do so I would retrieve the logged in user's user
$user = JFactory::getUser();
$username = JUserHelper::getUsername($user->id);
Then, the MySQL query would look something like
SELECT Name,Mail, Phone FROM #__rsforms_submissions WHERE Username = $username
However, what's next? How do I insert these values into the PHP code? Thanks!
Dani