I want to put the photos in the uploads folder but when I try to call the variable from the controller to the view it generates an Undefined Variable error
File : application/controllers/ubah_profile.php
public function ubah_profile()
{
$data['foto'] = $this->db->get_where('user',array('id'=>$this->session->userdata('id')),1)->row()->foto;
$this->load->view('top',$data);
$this->load->view('upload_foto');
$this->load->view('bottom');
}
File : application/views/top.php
<ul class="nav navbar-nav">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?php echo base_url() ?>uploads/<?php echo $foto; ?>" class="user-image" alt="User Image">
<span class="hidden-xs">Admin</span>
</a>
</li>
</ul>
You should change the form type my friend.
That’s why the controller can’t recieve the file info.
Btw, judulnya ada campuran bhs indo wkwk.
Related
At the beginning I want to say that all the code presented below works well if put in right environment. I only have an issue with php in wordpress menu navigation that seems not to be able to work.
I'm trying to print user's role (there's only one role a user can have at a time) in a dropdown. PHP code:
<?php
$user = wp_get_current_user();
echo $user->roles[0]; ?>
dropdown code:
<ul id="primary-menu" class="navbar-nav ml-auto"><li class="nav-item menu-item menu-item-type-gs_sim menu-item-object-gs_sim">(Untitled)<small class="description"></small><small class="description"><div class="dropdown show"><a href="" class="nav-link">
</a><a class="nav-link btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<img src="http://ds.com/wp-content/uploads/ultimatemember/1/profile_photo-40x40.png?1561371663" class="gravatar avatar avatar-40 um-avatar um-avatar-uploaded" width="40" height="40" alt="pzo3xic" data-default="http://ds.com/wp-content/plugins/ultimate-member/assets/img/default_avatar.jpg" onerror="if ( ! this.getAttribute('data-load-error') ){ this.setAttribute('data-load-error', '1');this.setAttribute('src', this.getAttribute('data-default'));}"> pzo3xic
</a>
<div class="dropdown-menu show" aria-labelledby="dropdownMenuButton">
<h6 class="dropdown-header" href="/user/">Paid Subscriber</h6>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/profile">View Profile</a>
<a class="dropdown-item" href="/private-lessons">Private Lessons</a>
<a class="dropdown-item" href="/logout">Log Out</a>
</div>
</div></small></li>
<li class="nav-item menu-item menu-item-type-taxonomy menu-item-object-category">Lessons</li>
<li class="nav-item menu-item menu-item-type-post_type menu-item-object-page">Tests</li>
</ul>
I want it to present as below (where "Paid Subscriber" is the user's role name):
But when I replace "Paid Subscriber" with my custom shortcode "[print_user_role]" it kind of displays the text instead of the function within. Let me point out here that my shortcode works well when added into other places.
Problem:
The avatar along with dropdown are all in a code added via Shortcode in Menus plugin. This plugin (and all the others) don't support php inside.
I have tried adding a shortcode into my custom_functions.php, then invoking it by pasting [my_custom_function_sc] into the code, however it returned nothing.
I lost ideas on how to achieve this effect. Does any of you see a possible solution here?
EDIT
I think that I might actually print the user's role somewhere else within a certain block, then with jquery copy the text within the block and paste in place that interests me. Does any of you have any ideas on how to achieve this? I haven't used javascript/jQuery really.
Many thanks
Your code seems to be correct except this line --> echo $user->roles[0];
The correct code is --> echo $user->roles;
i want to change the dropdown language item in opencart to a static selection model, so both languages can be shown always and the user doesnt have to hover on the language flag to see the other language.
So I think i should change the language file in theme, and in following you can see the code, so what parts should i change? I believe I should change the type of the item from dropdown to something else?
<div id="language">
<div class="btn-group">
<button class="dropdown-toggle" type="button" data-hover="dropdown">
<?php echo $current_language; ?> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<?php foreach ($languages as $language): ?>
<?php if ($type === 'flag'): ?>
<li><a onclick="$(this).closest('form').find('input[name=\'code\']').val('<?php echo $language['code']; ?>'); $(this).closest('form').submit();"><img width="16" height="11" src="<?php echo Journal2Utils::staticAsset('image/flags/' . $language['image']); ?>" alt="<?php echo $language['name']; ?>" title="<?php echo $language['name']; ?>" /></a></li>
This isn't really a programming question this is more of a task that you're looking for someone to do for you for free.
You should look for an extension in the marketplace (https://www.opencart.com/index.php?route=marketplace/extension) and if there isn't one you should pay a developer from the Commercial Forum (https://forum.opencart.com/viewforum.php?f=88).
I hava a page having multiple picture in grid view loaded though a php loop as follows
<?php if($rows){
$i = 0;
while($resImage = mysqli_fetch_array($fetchImg)){?>
<div class="col-md-4">
<div class="user-box">
<h6 class="view-gallery-btn"><?php echo $resImage['image1']; ?></h6>
<?php $imgPath = base64_decode($_REQUEST['gallyId'])."_".$_SESSION['unique_id']; ?>
<i class="fa fa-cloud-download" aria-hidden="true"></i>
<img src="poweradmin/Gallery/<?php echo $imgPath?>/<?php echo $resImage['image1']; ?>" alt="" class="img-fluid">
<ul class="new-gallery-btn add-listing-gallery">
<li>
<i class="fa fa-star" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-trash-o" aria-hidden="true"></i>
</li>
<li>
<input name='ids[]' type='checkbox' id='ids' class="form-check-input custom-check-box checkboxes" value="<?php echo $resImage['id']; ?>">
</li>
</ul>
</div>
</div>
<?php } } ?> `
each image has a star icon that invokes an Ajax code as follows
$("a.redFav").click(function(){
var current = this ;
var status_id = $(this).attr('href').split('=');
var arr = status_id[1];
$.ajax({
type:'post',
url:'addUserPics.php',
data:{arr: arr},
success:function(msg){
console.log("User Like Applied");
$(current).toggleClass("user-fav");
}
});
return false;
});
this calls a php file that updates the corresponding field in the database but the issue is that if there are many images in the page ( ie around 100+ ) and some of them are selected (ie the icon calling Ajax is clicked ) eg 10 only few of them are updated. Each time the success stats are different it seems that its due to Ajax call delay or incomplete calls.
Kindly suggest a way to handle the same.
I am working on local machine and my URL is:
http://localhost:91/GlobalVision/index.php?mm=1&sm=1
<? $mm=$_GET["mm"];
$sm=$_GET["sm"]; ?>
<ul class="sidebar-menu">
<li class="header">MAIN NAVIGATION</li>
<li class=" <? if($mm==1) echo "active" ?> treeview">
<a href="#">
<i class="fa fa-dashboard"></i> <span>Dashboard</span> <i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li <? if($mm==1 && $sm==1) echo "class=\"active\"" ?>><i class="fa fa-circle-o"></i> Dashboard1</li>
<li <? if($mm==1 && $sm==2) echo "class=\"active\"" ?>><i class="fa fa-circle-o"></i> index2</li>
</ul>
</li>
</ul>
i have created this file as separate menu file and included in other php files.
i wanted url as:
http://localhost:91/GlobalSDK/index
I tried writing:
^([a-zA-Z]+)/$ index.php?mm=$1&sm=$2 [L]
this rules in .htaccess file but it gives me error.
What should be the rule to achieve this. Even when index page get change it should display only page name not parameters. What should be the rule for this?
Try these methods
1) Use a form and POST the information.
2) Use session variables to carry information from page to page.
3) Use "encoded" or non-sensical information in the QueryString in
place of the real data.
I have this code on my php file for navbar:
<?php if(!$session->is_logged_in()) {
echo '
<a href="login.php" role="button" aria-expanded="false">
Login <span class="label"> login to system</span> </a>
</li>';}
else
{
echo '
<a href="#!" class="dropdown-toggle" role="button" aria-expanded="false">
' . $session->user_name; . '<span class="badge bg-default">2</span> <span class="caret"></span> <span class="label">it is you</span>
</a>';
}
?>
I check if the session is set using (!$session->is_logged_in())
If it is not set I should get a login button on navbar.
If the session is set, I should get his username ($session->user_name).
On my website I have a preloader (astral-gaming.com) but after inserting this code and uploading this file, every page which had included it, isn't shows.
It's just the preloader and it doesn't go to the page.
After deleting that code, everything is fine.
What I should do?
Remove the ; after$session->user_name;