I am currently working with some legacy flash files that submit POST data based on some actions. Problem is I am unable to edit the flash file and flash seems to be submitting to the controller method the flash file is currently on + index.php.
It is fine that its submitting here, I'm just trying to figure out a way to catch it. Everything I attempt continues to return a 'NotFoundHttpException'.
I am currently trying to catch it with:
public function postMethod()
{
}
Any suggestions?
Is the route making it past your htaccess intact? Can you show your routes file? If the route is coming through OK surely you can just match RouteWithFlashFile/index.php to a method in your controller. Something like this:
Route::post('RouteWithFlashFile/index.php', 'MyController#processFlash');
If that doesnt work, you might have to look at reworking your htaccess to map the route to something else. I will confess this is all speculation as I've never stuck index.php in the middle of a route before.
Related
Moved existing codeigniter app to a new server to perform some code updates. Everything is working correctly except any method that uses POST returns 404.
For example:
function export_xls(){
echo "HERE";
if($this->input->post()){
I'll be able to hit the echo but it will then 404 at
$this->input->post()
I've tried changing base_url in config.php and different things in htaccess to see if that helps but nothing has proven successful.
All other functions where post values are not being called work perfectly.
Live url (where everything works) is http://admin.xxxxxx.com and dev is http://crm-admin.srv-y7z9u.xxxxxxx.com if that provides any insight.
Try to check for some issues that can get in the way.
First see if the link is being directed to the page correctly, then follow some steps that can help you:
Check base_url in your project settings.
Make sure you have not entered the wrong direction, as is quite common: http://crm-admin.srv-y7z9u.xxxxxxx.com/saveForm
see also $.post to Codeigniter Controller/Method 404 Page Not Found
I am new to CodeIgniter and also have average PHP knowledge. Just started learning CodeIgniter last week and having a basic problem which i can't overcome. my development environment is (OS,PHPStorm,MAMP,APACHE). CI project root is http://localhost:63342/CodeIgniter/ and this address loads my 'default_controller' (login.php in Controllers folder). this controller redirect me to my view "$this->load->view('login_view');". in my view i have a form with this line: which supposed to take me to my form.php in Controller upon the form being submitted but it does not! when i submit i am taken to a url : http://127.0.0.1/CodeIgniter/form with error message "connection attempt to 127.0.0.1 was rejected.".
Also when i try to type a url (i.e. BASE_URL()./index.php/form) or amy other URL in fact, i get errors too. i was under impression that navigating through pages in CI is as simple as typing the name of the file and the method in it in my Controller folder. what am i missing here? any attempt to navigation through URL i get "404 Not Found" error. i am sure i am missing something very simple here but i can't figure out what. i have read the documentations and search the web and no answer is found. i have changed the .htdaccess in root, tried the enable mode in Apache, done all the necessary changes in Config.php , routes.php etc. i would appreciated it if you can tell what am i doing wrong here. i wasn't expecting getting started with CI to be this hard :s
cheers
It seems you "loose" the port (63342) when you redirect. What is the action of your form? If this is an url like "http://localhost/CodeIgniter/form", you should add the port : http://localhost:63342/CodeIgniter/form
You can output set your login form's action by using the URL helper.
site_url('form')
http://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=site_url#site_url
Ok I have a controller named Login and have an index() function that displays the view user/login. I build the urls with user/login, but with the redirect, I'm doing this:
redirect('/user/login/');
But I've also tried redirect('/login/');
How comes my login won't load? It keeps giving me a 404 error...
I've also tried ('/login/index') and ('/login')
It sounds like you have only one controller, Login, with only one page, index, in it, so why do you need a redirect? Are you just trying to get your index page to show your login view? If so you do that with something like:
$this->load->view('path/to/view');
you can try redirect(site_url("login"));, if you haven't changed the relevant routing in your CI install it will take you to the login controller (and the index() method by default)
edit: I misread the question
Ah.. sorry, my bad. I have an if statement that isn't even letting it get to the redirect part... I'm sorry!
so I hope someone would help me.
My first page is leave_app.php. In this page I put a link to apply leave, using the normal code:
New Leave Application
However the link didn't display as I had wished for.
"The requested URL /ci/add.php was not found on this server." and the link in the browser leads to this "http://localhost/ci/add.php".
I don't know why the server didn't find the page. I already made add.php page, also add at the leave_app controller the function add().
In the config.php file I put $config['index_page'] = '';
I have asked around but no one can help. I have already surfed around, but still don't know how to solve.
The beauty of Codeigniter is to rewrite urls in a clean manner, so all things go through index.php and the corresponding controller is loaded
Try accessing it like so:
/ci/index.php/add
Make sure your controller is in application\controllers\add.php and named Class Add
When Ive created a new controller, ie in this case Authenticate, Ive also created the folder and file application/views/scripts/authentication/index.phtml
Not a problem when hitting the url http://dev.local/authentication/ but when calling any action ie http://dev.local/authentication/login, I get the error below.
Message: script 'authentication/login.phtml' not found in path (C:\Sites\application\views\scripts\)
Regardless of any changes Im going to make to the login action it shouldnt automatically ask for a new page right? or am I wrong?
By default, each action requires its corresponding view (phtml page). If you want to disable a view/layout for a given action, you can use the following code :
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
EDIT in response to the comment:
I usually don't need to do this, because the actions I have that don't need a view script are redirected/forwared to other actions. For example, once your user is authenticated (i.e. when /authentication/login succeeds), you can redirect him to the home page (or whatever page he was trying to access. Similarly, if the login failed, I simply set an error message in the view and forward to the action that shows the login form.
The only actions for which I use the above code is for actions that are typically called using AJAX and that output some JSON code, for example.