Welcome Guest, Not a member yet? Register   Sign In
form_open question
#1

[eluser]Sire[/eluser]
I'm posting an input text field to a form_open('controller/method') and using the uri_segment in the method. However, the search form url in the form is being appended.

it starts looking something like domain.com/index.php/controller/method
then it works fine but the form_open has then given me a post to action=domain.com/index.php/controller/controller/method

Have you run into this and found a solution using form_open? for now I hardcoded the url to just action="/controller/method"
#2

[eluser]stuffradio[/eluser]
No one can give you the best help until you post the code you're using when that happens. Please do that and I'll try answering the question Smile
#3

[eluser]Jeroen Brussich[/eluser]
http://codeigniter.com/wiki/How_to_ask_a_good_question/
#4

[eluser]theprodigy[/eluser]
have you tried 'form_open('/controller/method')' (put a slash in front of the controller)?
I'm not sure if it would work, but it's worth a try
#5

[eluser]Sire[/eluser]
That is the code I used. Without the slash in front. A form_open tag. What other code should I be showing?

At domain/index.php/controller/ is the form, a search form. I view the source and it posts to domain/index.php/controller/search. I enter the keyword and submit the form.
Code:
<?php echo form_open('controller/search'); ?>

It works and returns the values. The form is rendered again on the same results page, but this time the source shows it posting to domain/index.php/controller/controller/search. It's adding 'controller/search' to whatever the current url is.
#6

[eluser]Sire[/eluser]
Problem solved. I just needed to understand that form_open appends to base_url to help me troubleshoot it, and my base_url was being changed dynamically by this config/config.php trick I was trying to implement. It must work ok in Apache, but behaves differently with nginx/fastcgi or at least the $_SERVER['PHP_SELF'] part of it.

Code:
$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '')
                      .'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['PHP_SELF']).'/');

I hardcoded the base_url instead, and now form_open() is working as expected.




Theme © iAndrew 2016 - Forum software by © MyBB