0

This is my base URL:

$config['base_url'] = '//'. $_SERVER['HTTP_HOST']. 
str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

This my view:

<form action="<?php echo $this->config->base_url().'index.php/certification/add/'; ?>" 
method="post" accept-charset="utf-8" onsubmit ='return false;'>

This is the result:

<form action="//localhost/php/index.php/localhost/php/index.php/certification/add/" 
method="post" accept-charset="utf-8" onsubmit="return false;">  

Why does this happen? (Read this if you don't know what protocol-relative URLs are.

Community
  • 1
  • 1
aWebDeveloper
  • 33,798
  • 37
  • 161
  • 232

3 Answers3

0

You never set the prefix http or https protocol to the base_url. So the form action url will start with // as expected.

Nish
  • 2,218
  • 2
  • 14
  • 19
0

It doesn't look like you are getting the base URL correctly. A similar question was already answered here.

Community
  • 1
  • 1
user1474090
  • 675
  • 6
  • 5
0

$config['base_url'] should not include the file/script path. If you echo it out on it's own, in your case, you should just be getting '//localhost/php/'

What are you trying to do with the additional SCRIPT_NAME stuff?

If I understand correctly you will want to get rid of that part and then use:

<form action="<?php echo $this->config->base_url('index.php/certification/add/')"

(I believe it will work as you have it now after removing the script part from the config, but I suppose this is the 'proper CI way' of doing it)

Tjkoopa
  • 2,188
  • 1
  • 16
  • 20