saguaros
Below are the code i am trying to use, i will try to add via root/templates/ja_intranet/tpls/blocks/head.php
<?PHP
$jinput = JFactory::getApplication()->input;
$foo = $jinput->get('id');
//get user id and user name
$user = JFactory::getUser();
//echo "<p>Your id is {$user->id}, Your name is {$user->name}, Your department is {$user->usertype},your email is {$user->email}, and your username is {$user->username}</p>";
$userid = $user->id;
$idname = $user->username;
$username = $user->name;
if ($userid != ""){
$db_server = "localhost";
$db_name = "db_test";
$db_user = "root";
$db_passwd = "";
if(!@mysqli_connect($db_server, $db_user, $db_passwd,$db_name))
die("Cannot connect to the database");
mysqli_query("SET NAMES utf8");
if(!@mysqli_select_db($db_name))
die("Cannot use database");
$s = "SELECT * FROM db_test.db_comprofiler where user_id = '" . $userid . "' ";
echo $s;
$query = mysqli_query("$s");
$row = mysqli_fetch_assoc($query);
$chinesename = $row["chinesename"];
$_SESSION['chinesename'] = $chinesename;
?>
<script>
// then echo it into the js/html stream
// and assign to a js variable
chinesename = '<?php echo $chinesename;?>';
var cn1 = document.getElementById("chinesename1");
var cn2 = document.getElementById("chinesename2");
var cn3 = document.getElementById("chinesename3");
var cn4 = document.getElementById("chinesename4");
var cn5 = document.getElementById("chinesename5");
if (cn1!= null){
document.getElementById("chinesename1").value = chinesename;}
if (cn2!= null){
document.getElementById("chinesename2").value = chinesename;}
if (cn3!= null){
document.getElementById("chinesename3").value = chinesename;}
if (cn4!= null){
document.getElementById("chinesename4").value = chinesename;}
if (cn5!= null){
document.getElementById("chinesename5").value = chinesename;}
</script>
<?php } ?>