Hi. I wanted to retrieve a data from a different table in database based on login user but somehow I can't make it work. This is how I wanted to get my data. Once the user click the submit button in the login page, I want to include the user name in the textbox and load/retrieve all data from another table based on the username automatically to the login redirect page like below but how can I do that? I guess my code is a mess. Please help. It's urgent. Thanks.
HTML Code to get data
HTML Code to get data
<?php
// Get user object -information from Joomla
$user= JFactory::getUser();
?>
Dear <input type="text" name="username" id="username" size="50" maxlength="40" value ="<?= $user->name; ?>" readonly />
<?php
$db =& JFactory::getDBO();
$query = "
SELECT 'username','district'
FROM `#__chronoforms_data_principal_project`
WHERE `username` = $user";
$db->setQuery($query);
$result = $db->loadObjectList();
echo "hello";
echo $result->username;
?>
<input type="hidden" name="h_username" id="h_username" size="50" maxlength="40" value ="<?php $result->username ?>" />
<input type="hidden" name="h_district" id="h_district" size="50" maxlength="40" value ="<?php $result->district ?>" />