I have a problem with CI whenever i click a button in a form which has an action of image/upload or a hyperlink with the same link it gets appended whenever i click it the second time. say for example my home is localhost/admin and i click a button or a link which has image/upload.. so the url will now beh localhost/admin/image/upload but when i click the same button the second time the url will now beh calhost/admin/image/image/upload wchich well then cause a 404 error which ofcourse is the error given that the page is not found by just seeing that url. it gets appended every time i click the button or the link.
Anyone of you knows this please do share!
UPDATES:
BTW just a headsup for all those people who didn't know or who encountered this problem.. USE anchor or any helper in CI becuase if you manually put links in href or actions on form tag without putting the base_url.. your URL will be messed up.. helpers do append base_url. :D
Check out the Codeigniter docs and the URL Helper. That should help out.
http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
I know for anchors you would just do:
echo anchor('image/upload', 'Upload');
This will append the url to the base url and you don't have to worry about changing anything or any 404 errors.
just put http:// at infront of your link.
or otherwise
change your config file:
$config['base_url'] = 'http://www.yourhost.com/home';
try to link the url as '/path-to-url'. notice '/' before url.
Link
currently you might be doing like below
Link
Also try changing
$config['base_url'] = 'http://localhost/home/';
Related
My page will redirect the user to another page which will handle all the updating information. I got the redirect in itself working, problem is, the URL isnt what i expect it to be, leading to a 404 error. Let me try to exemplify.
The user clicks a button, redirecting him to "test.com/main/update.php". But my file is in "test.com/test/RazorFinger/update_test.php". so it ends up being something like this:
<FORM name=form id="form" action="test.com/main/update.php?area=<?=$GetArea?>&etc..." method="POST" target='_blank'>
So my main URL is this:
http://test.com/teste/RazorFinger/update_test.php?area=TestArea&proj_id=1234&task_uid=1
And the redirected url is basically:
http://test.com/teste/RazorFinger/test.com/main/update.php?area=TestArea&etc..etc..etc..
The question might be a bit complicated because i'm using fake URLs as example, but basically, i can't get out of "test.com/test" and into "test.com/main", and that leads me to a 404 error. So what's wrong?
put http:// (or https:// if you use SSL) in font of the url.
<form action="http://test.com">
This will lead to the URL http://test.com
<form action="test.com">
This will lead to the URL http://test.com/test.com
you are passing the whole url in the action so this code will obviously give an error.
Replace action by action="test.com. u will get correct result
i have this button which is on one page and when user clicks on it, it is supposed to redirect to the page mentioned.
<div id="backicon"><img src="com/resources/images/backicon.png"></div>
href is supposed to work with the php and it should redirect to the default_home page, but nothing happens on click. i believe i am missing a thing or two about php code inside html tag?
i also tried
Back
but of no use, any help?
This returns the PSF:urlFor, but doesn't echo it. Try it like so:
<div id="backicon"><img src="com/resources/images/backicon.png"></div>
I've a hyper-link when we're clicking on hyper-link it got a parameter of year but it can't load data based on year and shows a blank page with continuously loading...
hyper-link :
<?php echo $this->Html->link('click me', array('controller'=>'dashboards', 'action'=>'myfunction', $year)); ?>
myfunction on usercontroller :
public function getsessionlist($year) {
$session = $this->find('all');
}
Right now i'm getting all data without any condition...
But it redirect on blank page
Calling $this->find('all') from the controller does not work unless you have a method called "find" implemented in the controller. This method is called on a model so edit the line to $this->User->find('all') in your case.
I think the redirection to the blank page is occuring due to the wrong mention of the controller/method name.
you can debug the problem by three methods:-
1.you can hard code the link and check if it redirects to the right page.
ex:
<a href='controllername/methodname?queries-if-you-have-any'>link name</a>
If this works out fine, then check the parameters you have passed in the link method.
2.You can debug the link from the browser console and see what is coming up in the "href" section of the link tag.
3.you can manually type the link in the url and see if the blank page is still coming up.
As per my client need , redirect the page without anchor tag and refresh page ,
and change the URL as per page appearance. I don't know any idea about this.
I can use ajax for page content. but I don't know the URL change option without
page refresh or redirect. how can I do this with ajax j-query. Any one guide me for this issue.thanks advance
sample url
www.samplesite.com/contact.php -> without anchor tag. and page refresh this url need to work on php.
I think you are looking for info about the new HTML5 History API ( pushstate ), this link has a detailed tutorial.
http://diveintohtml5.info/history.html
You can do this using below function.
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
You can use the following javascript functions
window.location.assign('http://www.samplesite.com/contact.php'); // keeps the current page in browser history
window.location.replace('http://www.samplesite.com/contact.php'); // replaces the current page in browser history
window.location = 'http://www.samplesite.com/contact.php'; // the same as assign() and is backward compatible even with the oldest browsers
jsfiddle
I am making a bookmarklet for my url shortener. What it does is it shortens the current url of a page when you click on the bookmarklet, so you don't have to go to a site to shorten a url, but what I need is for the bookmarklet to return a pop-up window with the shortened url listed below.
What I've done so far is this:
javascript:u=encodeURIComponent(location.href);s='http://n1x.co.uk/create.php?url='+u;window.open(s,'shortened','location=no,width=400,height=300');
If you have bookmarked this, you will notice when you click on it, it does shorten the url of the current page, but it also shows the url shortener webpage, and what I only need is plain text and a link to copy it.
Please help!
Edit: Sorry I'm that bad at php, but how can I make a parameter "responseType"? Thanks
What is shown in the popup is what is returned by http://n1x.co.uk/create.php. You will have to modify the php to return only the shortened url in plain text. If the php is being used by the shortener site also, what you can do is pass a parameter to create.php that tells it whether to return the whole page like it does now or to return only the plain text url. For example a parameter called 'responseType'. You can modify the create.php to say that when responseType = 'plainurl', return simply the shortened url and not the whole page.
javascript:u=encodeURIComponent(location.href);s='http://n1x.co.uk/create.php?url='+u + '&responseType=plainurl';window.open(s,'shortened','location=no,width=400,height=300');