problem with link and url |
[eluser]Unknown[/eluser]
hello. I'm new user of codeigniter framework. I created a view that has a form with action attribute. value of action is "email/send". 'email' is controller and 'send' is method that send email by getting form parameters from view. this view load in index() method of email controller. ok? now when my url is 'localhost://codeigniter/email' every thing is fine (I mean url change to 'localhost://codeigniter/email/send'). but when my url change to localhost://codeigniter/email/' and I press the submit button my page goes to this address: 'http://localhost/codeigniter/email/email/send' and in this address I see my view again. I want my web application has same behavior for url with & without "/" at the end of them. I have this problem with simple anchor tag . I tried by put $config['url_suffix'] = '/'; in config.php but it didn't help me. please help me about this problem
[eluser]Glazz[/eluser]
What is your html form method and form action ? What i mean is: <form method="post" action="the page you go after submiting the form"> Maybe you have <form method="post" action="send"> And when you submit your form it goes to the send page ?!? Btw, try to use the ENTER KEY more, it's a little bit difficult to read your post :\
[eluser]InsiteFX[/eluser]
Your base_url should be: Code: $config['base_url'] = 'http://localhost/codeigniter/';
[eluser]Unknown[/eluser]
My form tag: <form method="post" action="send/email" > And I changed my action value to <?php echo base_url(send/email)?> My problem solved. I think should use base_url() for every internal link. I think true?
[eluser]InsiteFX[/eluser]
If your base_url is not set right it will never work!
[eluser]PhilTem[/eluser]
It's even easier to use the form_helper since it will make any relative link work At least as long as the base-url is set up correctly!
[eluser]Aken[/eluser]
Use site_url(), not base_url(). site_url() will include the index.php in your links if it is assigned. Good for having your website still work properly without an .htaccess file. The form_open() helper function uses site_url(), as an example. |
Welcome Guest, Not a member yet? Register Sign In |