0
votes

I'm having issues with submitting forms in Codeigniter. When I click the submit button to log in, it routes to a URL like this: domain.com/www.domain.com/home/login. Obviously, it should just be www.domain.com/home/login.

This seems to be a similar problem to this question: Code Igniter URL appending, but that user was using regular forms, whereas I am using the CodeIgniter forms. In his question, using CodeIgniter forms was the correct answer to fix this issue, however, I'm still having the same issue he was.

My base_url() is already set in the configuration, and I've tried both

$this->load->view('/home/home');

and

$this->load->view('home/home');

in the controller function. I still get the same thing every time.

Even when the function is empty, and is literally just

public function login(){}

I still get the double domain issue.

As it may be relevant, here is my .htaccess file:

RewriteEngine On
RewriteBase /eventCentral/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

The RewriteBase is necessary, as this is a mock site piggybacking on my main site.

Here is the code for the form_open tag:

               echo form_open('home/login');
               echo form_input($userNameField);
               echo form_password($passwordField);
               echo form_submit($submitButton);
               echo form_close();

I've also tried the form open tag as: echo form_open('/home/login'); and it still gives me the same issue.

My base_url is:

$config['base_url'] = 'www.redwolff.info/eventCentral';

The only route I have changed is is

$route['default_controller'] = 'Home';

The rest are all what they were before.

1
Show your code that is generating your form open tag, or if you're just using raw HTML show that. - Brian Gottier
Done. I think this is somewhat related to the question you helped me with earlier. My teacher showed us how to set up code igniter earlier in the year, but the class is over now, and this didn't happen in his class, so I'm at a complete loss as to why it's happening now. I've followed his videos to get to this point. The only difference is before we were working on a linux server that we built in class, and now I am working on hostgator. - Randall Wolff
Your form open tag should be fine. Will you please show me what you have for your base_url in config/config.php. Also, do you have any non-default routes in config/routes.php ? - Brian Gottier
I added it to the text above. - Randall Wolff
Thanks @BrianGottier. That was the issue. - Randall Wolff

1 Answers

0
votes

Your base URL is not set properly. You must always include the http:// or https://, and you most always include a trailing slash. Change your base_url to:

$config['base_url'] = 'http://www.redwolff.info/eventCentral/';