Welcome Guest, Not a member yet? Register   Sign In
change the URL to something more friendly
#1

[eluser]mistress_shiira[/eluser]
hi guys!
i have a controller that loads a certain view file.
the URL seen on the browser is this:
http://localhost/CodeIgniter_1.5.3/index.php/Admin
that view file basically shows a log in page.i have a function in my controller that checks for validation.
in my view file i have this line
<form id="admin" method="post" action="validate">
where validate is the name of the function that checks for validation
after it has validated,it would go to another view called main.php
the url becomes this:http://localhost/CodeIgniter_1.5.3/index.php/Admin/validate
how will i be able to change the url so that what is reflected is the base url and the actual name of the page?
#2

[eluser]gtech[/eluser]
Firstly have you checked out the form validation class?
Quote:how will i be able to change the url so that what is reflected is the base url and the actual name of the page?

what is being reflected is the baseurl, the name of the controller and then the name of the function, I am not sure why you want to change it?

however you can change the url mapping by using [url="http://ellislab.com/codeigniter/user-guide/general/routing.html"]uri routing[/url]
#3

[eluser]mistress_shiira[/eluser]
actually want i wanted to reflect is this:
http://localhost/CodeIgniter_1.5.3/index.php/Admin /main

where main is the name of the view file loaded after successful validation
i dont want it to reflect the name of the function that did the validation.

much better if i can achieve this URL:
http://localhost/CodeIgniter_1.5.3/main

thanks a lot!
#4

[eluser]gtech[/eluser]
not tried it, but it sounds like URI routing is what you need. click on the link in my first reply.
#5

[eluser]llbbl[/eluser]
make another class called main.php in controllers directory that loads the main.php in the views folder. send the user to /main after the form is validated. that will call the main.php in controllers directory. Smile
#6

[eluser]gtech[/eluser]
[quote author="llbbl" date="1194585183"]make another class called main.php in controllers directory that loads the main.php in the views folder. send the user to /main after the form is validated. that will call the main.php in controllers directory. Smile[/quote]

I think that might make the url


http://localhost/CodeIgniter_1.5.3/index.php/main
instead of:

http://localhost/CodeIgniter_1.5.3/main

mind you that might be what they want
#7

[eluser]llbbl[/eluser]
the first url u have is correct. the 2nd is correct if she has configured her .htaccess file to remove the index.php.

however I dont think you understand what she was trying to ask. She didn't know how to send the user to a url /main after they where authenticated.
#8

[eluser]gtech[/eluser]
[quote author="llbbl" date="1194586326"]the first url u have is correct. the 2nd is correct if she has configured her .htaccess file to remove the index.php. [/quote]
I didn't actually know that.. you learn something new every day.

Quote:however I dont think you understand what she was trying to ask. She didn't know how to send the user to a url /main after they where authenticated.
your right I did misinterpret the question, case of scanning the question and not reading it properly. sorry for that.
#9

[eluser]llbbl[/eluser]
no prob bob
#10

[eluser]Phil Sturgeon[/eluser]
URL routing is one but that strikes me as a little silly.

You might preffer to try

Code:
if($this->validation->run() != FALSE):
redirect('main');
endif;




Theme © iAndrew 2016 - Forum software by © MyBB