Php-Codeigniter image not found

I had earlier posted about the PHP undefined variable issue i was facing, but i managed to solve it somehow and after that there is a small element that is not working if i could be helped with. So it is an online noticeboard system for a school and it has a users dashboard, teachers, and the admin. So the users dashboard is okay except when a user uploads a picture, it says not found technically i was having issues regarding the image as a undefined variable, and now it says not found. Earlier it was all working well.  also there is something about the user's updating password, when they update a password, says successful then when u log out and log in with the old password, i yet manage to log in with both old and new passwords. what could be the issue there?
Below is attached a screenshot for how the user dashboard looks like.
so here is the user's view for dashboard_header page:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Online Notice Board User Dashboard</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo base_url()?>public/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="<?php echo base_url()?>public/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<?php echo base_url()?>public/css/dashboard.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="<?php echo base_url()?>public/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#"> Student </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
           
            <li><a href="<?php echo site_url('user/logout');?>">Logout</a></li>
          </ul>
          <!--<form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="Search...">
          </form>-->
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="<?php echo site_url('user/home');?>">Dashboard <span class="sr-only">(current)</span></a></li>
			<!-- find users' image if image not found then show dummy image -->
			
			<!-- check users profile image -->
			
      <li><a href="<?php echo site_url('user/sysusers/update_profile_pic');?>"><img title="Update Your profile pic Click here" style="border-radius:50px" src="<?php echo base_url()?>data/images/profile/<?php echo $imgdetails;?>>" width="100" height="100" alt="not found"/></a></li>
      
	
			<li><a href="<?php echo site_url('user/sysusers/update_profile_pic');?>"><span class="glyphicon glyphicon-user"></span> Update Picture</a></li>
			
			
			
			<li><a href="<?php echo site_url('user/sysusers/pupdateinterface');?>"><span class="glyphicon glyphicon-user"></span> Update Password</a></li>

            <li><a href="<?php echo site_url('user/sysusers/updateprofile');?>"><span class="glyphicon glyphicon-user"></span> Update Profile</a></li>
			 
            
          </ul>
         
         
        </div>

Open in new window

here is the controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//session_start(); //we need to call PHP's session object to access it through CI
class Home extends CI_Controller {

  
	
	public function __Construct()
	{
	   	parent::__Construct();
	   	$this->load->model('user/user_model');
	   
	}	
	
	public function index()
	{
	if($this->session->userdata('logged_in'))
   {
  	    $_SESSION['logged_in'];
   		$data['title']='Home';
     	$session_data = $this->session->userdata('logged_in');
     	$data['id'] = $session_data['id'];
     	$data['username'] = $session_data['username'];
     	$data['grade'] = $session_data['grade'];
     	
    	$this->viewForm($data);
   }
   else
   {
     //If no session, redirect to login page
	 redirect('user/sysusers/userlogin');
   
   }
		
	}	
		
	private function viewForm($data=''){

	$result=$this->user_model->getNotices($data);
	
				if($result!=FALSE){
					$data['files']=$result;
				}else{
					$data="No List Found";
				}	


   		$id=$data['id'];
     $result2=$this->user_model->imageDetails($id);
       
          if($result2!=FALSE){
					foreach ($result2  as $value):
                                    $data['imgdetails']=$value->image; 
             
                                   endforeach;
				}else{
					$data="No List Found";
				}	

	

		$data['title']='Home';
	  

		$this->load->view('user/template/dash_header',$data);	
		$this->load->view('user/userdashboard',$data);
		$this->load->view('user/template/dash_footer');
		
						
	}
	
}

Open in new window

and here is the model
<?php 
class User_model extends CI_Model{
	public function insert($data = array()){
        $insert = $this->db->insert_batch('images',$data);
        return $insert?true:false;
    }
	public function insertuserdetails($data=array()){

	$insert=$this->db->insert('user',$data);
    return $insert?true:false;
     }
	public function read_user_information($username) {
		$condition = "email =" . "'" . $username . "'";
		$this->db->select('*');
		$this->db->from('user');
		$this->db->where($condition);
		$this->db->limit(1);
		$query = $this->db->get();
		if ($query->num_rows() == 1) {
		return $query->result();
		} else {
		return false;
		}
}
public function getNotices($data) {
	        $var=$data['grade'];
	        $general='General';
$this->db->select('*');
$this->db->from('notice');
$this->db->where("grade",$var)->or_where("grade",$general);
$query = $this->db->get();
		if ($query->num_rows() >0) {
		return $query->result();
		} else {
		return false;
		}
}
public function imageDetails($id){
$this->db->select('*');
	$this->db->from('images');
	$this->db->where('userid',$id);
	$query=$this->db->get();
	if($query->num_rows()>0){
		return $query->result();
	}else{
		return false;
	}

}
public function profilepictreupdate($fi,$userid){

     $this->db->set('image',$fi);
        $this->db->where('userid',$userid);
        $this->db->update('images');

	
}
public function updatepass($id,$newpassword){
            $this->db->set('pass',$newpassword);
            $this->db->where('id',$id);
            $this->db->update('user');


  }
  public function read_user_details($id) {
		$condition = "id =" . "'" . $id . "'";
		$this->db->select('*');
		$this->db->from('user');
		$this->db->where($condition);
		$this->db->limit(1);
		$query = $this->db->get();
		if ($query->num_rows() == 1) {
		return $query->result();
		} else {
		return false;
		}
}
public function updateprofiledetais($data,$id){
          	$this->db->where('id',$id);
            $this->db->update('user',$data);

}
public function getNoticeById($id){
	$condition = "notice_id =" . "'" . $id. "'";

	   	$this->db->select('*');
		$this->db->from('notice');
		$this->db->where($condition);
		$this->db->order_by("notice_id", "desc"); 
			$query=$this->db->get();
		if($query->num_rows()>0){
			return $query->result();
		}else{
			return false;
	  }
}

public function getNoticeBySubject($id){
	$condition = "subject =" . "'" . $id. "'";

	   	$this->db->select('*');
		$this->db->from('notice');
		$this->db->where($condition);
		$this->db->order_by("subject", "desc"); 
			$query=$this->db->get();
		if($query->num_rows()>0){
			return $query->result();
		}else{
			return false;
	  }
}
}

Open in new window

Screenshot--140-.png
Amrit KaurAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Hey Amrit,

You have a slight typo in your view code. You currently have this:

src="<?php echo base_url()?>data/images/profile/<?php echo $imgdetails;?>>" width="100"

Open in new window

And it should be this:

src="<?php echo base_url()?>data/images/profile/<?php echo $imgdetails;?>"> width="100"

Open in new window

The closing tag on the <img> element had the > and " the wrong way around.

There look to be a couple of other logic issues with your code, but fix the above first and then we can address the other issues if needed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
Just another thought Amrit ... when using base_url(), you can pass a path into it directly, so you could do this instead:

src="<?= base_url("data/images/profile/$imgdetails") ?>">

Open in new window

Just makes your code a little cleaner :)
Chris StanyonWebDevCommented:
Sorry ... now I've made a mistake (been a long day!). There is still an extra > in the code. It should look like this:

src="<?php echo base_url() ?>data/images/profile/<?php echo $imgdetails; ?>" width="100"

Open in new window

or this:

src="<?= base_url("data/images/profile/$imgdetails") ?>" width="100"

Open in new window

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Amrit KaurAuthor Commented:
Thank you so much! helped me out by far!!  Everything seems alright to me now, just one small issue, i don't know if you might be able to help me?
Chris StanyonWebDevCommented:
Hey Amrit,

I'll try if you let me know what your issue is
Amrit KaurAuthor Commented:
sure, it is actually to do with the responsiveness, like the index page is responsive, but once for example when the admin logs into their dashboard, i tried to check the responsiveness and i only get the responsiveness of the log-out option which is on the navbar, and there are option on the left side out the navbar which dont show when i check the responsiveness. Here is the code of the view:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Online Notice Board Admin Dashboard</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo base_url();?>/public/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="<?php echo base_url();?>/public/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<?php echo base_url();?>/public/css/dashboard.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="<?php echo base_url();?>/public/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Welcome Admin <?php echo $username;?></a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
           
            <li><a href="<?php echo site_url('admin/Logout');?>">Logout</a></li>
          </ul>
          <!--<form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="Search...">
          </form>-->
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="<?php echo site_url('admin/home');?>">Dashboard <span class="sr-only">(current)</span></a></li>
			<!-- find users' image if image not found then show dummy image -->
			
			
            <li><a href="#"><img src="<?php echo base_url();?>/public/images/person.jpg" width="100" height="100" alt="not found"/></a></li>
			
			
			
			
		<li><a href="<?php echo site_url('admin/admin/pwdupdate');?>"><span class="glyphicon glyphicon-user"></span> Update Password</a></li>
    <li><a href="<?php echo site_url('admin/admin/manageusers');?>"><span class="glyphicon glyphicon-user"></span> Manage Users</a></li>
   
    <li><a href="<?php echo site_url('admin/admin/addnotice');?>"><span class="glyphicon glyphicon-envelope"></span> Add notice</a></li>
   
    <li><a href="<?php echo site_url('admin/admin/addteacher');?>"><span class="glyphicon glyphicon-user"></span> Create Teacher Profile</a></li>
     <li><a href="<?php echo site_url('admin/admin/listofteachers');?>"><span class="glyphicon glyphicon-user"></span> List of Teachers </a></li>
    
          </ul>
         
         
        </div>

Open in new window

The part to update passowrd, manage users, add notice, create teacher's profile... etc the last part of the lists.. How can i make that responsive? I can attach a picture for you to have a better look at it:, only the log-out top right is what shows on the drop down menu when i minimize screen... the option on the left side dont show at all.
Screenshot--141-.png
Chris StanyonWebDevCommented:
Hey Amrit,

The way you've coded your page means that only the top navigation is aresponsive menu. You have this code:

<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">

Open in new window

Notice the data-target property - #navbar. This means that the toggle button will only toggle the #navbar element on and off in a responsive view. Your left hand menu is a completely different element so won't get included.

What you probably need to do is repeat your side menu in the top menu and then use the various display classes, such as .d-sm-block and .d-sm-none. The sm part is the size of device, so you can choose when to show and hide various elements, so your top menu would probably need to look like:

<div id="navbar" class="navbar-collapse collapse">
    <ul class="nav navbar-nav navbar-right">
        <li><a href="<?php echo site_url('admin/Logout');?>">Logout</a></li>
        <li class="d-md-block d-lg-none"><a href="#"><img src="<?php echo base_url();?>/public/images/person.jpg" width="100" height="100" alt="not found"/></a></li>
        <li class="d-md-block d-lg-none"><a href="<?php echo site_url('admin/admin/pwdupdate');?>"><span class="glyphicon glyphicon-user"></span> Update Password</a></li>
    </ul>

Open in new window

If you look at the code above, you'll see 2 of the menu items in the navigation now have these classes : d-md-block d-lg-none

This means that they will only show when the device size is below medium, so in full screen mode, you won't see them, but as soon as your responsive menu kicks in, they will be visisble.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.