• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
empty variable

#1
i want the credentials of a logged in user to display in his profile.like name and other values but the $username variable is for somereasons showing nothing at all.it is empty and displays no value at all.
my view file is

    <!DOCTYPE html>     

<!-- Without needing extra details only username and email can be obtained from session data -->
<?php
if (isset($this->session->userdata['logged_in'])) {
$username = ($this->session->userdata['logged_in']['username']);
$email = ($this->session->userdata['logged_in']['email']);
} else {
  $location = base_url();
header("location:".$location);
}
?>
<!--  -->
<html>
<head>
    <title>profile</title>
</head>
<body>
<p><?php echo $username; ?></p>
<p><?php echo $data[0]['username']; ?></p>
<!-- Since now data is in array form because of $query->result_array $data[0]['username'] is suffice -->

<img src="images/home-user-icon.png" style="width:150px"; height:150px; float:left; border-radius:50% ; margin-right:25px;">
<?php echo form_open_multipart('main/save');?>
<table class="table">

<tr>
<td>image</td>
<td><?php echo form_upload('pic');?></td>
</tr>
<tr>
<td></td>
<td><?php echo form_submit('submit','save','class="btn btn-primary"');?></td>
</tr>
<div>
<table class="friends">
</body>
</html>


and my controller part is
"public function index(){
        //plz  enter the code here to fetch the data of logged in user so that i can use the logged in user's information in the view main.php.
    $username = $this->session->userdata['logged_in']['username'];
    $result['data'] = $this->Login_Database->read_user_information($username);
    // Change has been made in Login_Database, Line108. $query->result is changed to $query->result_array

    $this->load->view('main',$result);
    
    }"
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.