Welcome Guest, Not a member yet? Register   Sign In
strange url changing ...
#21

[eluser]raimon[/eluser]
[quote author="gtech" date="1195618431"]No I just undrstand why you are getting the error, as you are loading the form in the index page of the default controller and so the two different urls can differ, and thats why you are having problems with the form open function..[/quote]

ok, I'll try to load the form from another controller ...


[quote author="gtech" date="1195618431"]you can just open a form in the normal way in HTML and put the full path in and not use form_open function.. or do what I put in post above and redirect to a differnet function[/quote]

yes, this is another solution ...


but anyway, it sounds so strange to me all of this ...

I'll keep you informed ...

regards and thanks again !!!!

raimon
#22

[eluser]gtech[/eluser]
no worries, sorry for the confusion..

[SOLUTION]

I did something sensible... I read the code for the form_helper.. and the form_open function!

there is a line that does
Code:
$form = '<form action="'.$CI->config->site_url($action).'"';

what site_url does is this:

$config['base_url'] + $config['index_page'] + / + <WHAT you CALL FORM open with>

SO if your base_url and index_page in the config is not set then form open will not put the full path in!. If the full path is not supplied it will only post relative to your URL, hence why you have problems.

sometimes I go the long winded way about doing things, but I get there eventually (lack of sleep)

P.S. this also explains why you have to set index_page to "" when you are using the .htaccess file to remove index.php.
#23

[eluser]raimon[/eluser]
Hi!

Code:
$config['base_url']    = "";
$config['index_page'] = "";


Code:
http://127.0.0.1/igni/
&lt;form action="user/validatelogin" method="post"&gt;
error 404, because I didn't include de index.php


Code:
http://127.0.0.1/igni/index.php/
&lt;form action="user/validatelogin" method="post"&gt;
it works, the new url is http://127.0.0.1/igni/index.php/user/validatelogin


Code:
http://127.0.0.1/igni/index.php/user/validatelogin
&lt;form action="user/validatelogin" method="post"&gt;

error, 404 not found ...

and the new url is:
Code:
http://127.0.0.1/igni/index.php/user/user/validatelogin
so, now I have two /user/ (/user/user/) .... :bug:

I'll try to dig in some examples or some more posts, as I don't want to disturb you more ...

maybe I should use a redirect for the login page, I don't know, I'll try more later, but I'm not getting how this really works, more study ...

thanks!

raimon
#24

[eluser]gtech[/eluser]
hi your using form action= not form_open

SO if your base_url and index_page is set properly in your config.php then it should work and put the full path, and what URL you have in your browser will not matter.

For Example

config.php
Code:
$config['base_url']="http://127.0.0.1/igni/";
$config['index_page']="index.php";

your view
Code:
&lt;?= form_open('user/validatelogin/'); ?&gt;

will produce http://127.0.0.1/igni/index.php/user/validatelogin/
#25

[eluser]raimon[/eluser]
Quote:hi your using form action= not form_open

no, I'm using form_open ...

Code:
&lt;?= form_open('/user/validatelogin/'); ?&gt;


I write the form action because is what I get in the html page, and you can see that it's wrong ...

but I'm going to start again from zero, through the tutorial, and see ...

thanks !

raimon
#26

[eluser]gtech[/eluser]
whats your config set to?

..\system\application\config\config.php

in the example you gave it was blank, it has to be set as in the reply above!
#27

[eluser]raimon[/eluser]
[quote author="gtech" date="1195654735"]whats your config set to?

..\system\application\config\config.php

in the example you gave it was blank, it has to be set as in the reply above![/quote]

I understand by your post, that for removing those extra paths (or repetead ones), I should remove the base and the index page ...

now both of them are blank, but yesterday where as the default ...

and the problem is more or less the same ...

I'll try again later with a fresh copy, and see ...

I'll keep you informed ...

thks!

r.
#28

[eluser]gtech[/eluser]
no no no don't keep them blank!!!....

you HAVE to set the config to

$config['base_url']="http://127.0.0.1/igni/";
$config['index_page']="index.php";

and the form_open will work

&lt;?= form_open('user/validatelogin/'); ?&gt;


if they are blank it WONT WORK Smile
#29

[eluser]raimon[/eluser]
:bug: :ohh: :gulp: :red: :-)

yes, now works perfectly ...

thanks a lot!!!!

r.


ps. After your post, I went to config.php to add your suggestions, and I found:

Code:
$config['base_url']    = "";// "http://127.0.0.1/igni/";
$config['index_page'] = ""; "index.php";

so, in one moment they were there, but maybe just only one, or something also was wrong ...

but now works ...

thanks again !
#30

[eluser]gtech[/eluser]
COOOOOOOOL !!!

its partly my fault as I was confusing the issue last night so sorry for that, but excellent news on getting it working Smile




Theme © iAndrew 2016 - Forum software by © MyBB