Form Value to URL |
[eluser]mjo1337[/eluser]
Hi, I'm converting a website into a Codeigniter based version I have a form which allows you to select colour, size and texture. The form uses GET method and produces search.php?size=65&colour=red&txtr=rough which the search script uses to pick the variables. How would i do this with CI? so i get something like this search/65/red/rough. Thanks
[eluser]tokyotech[/eluser]
I usually use $_POST for forms, but it can be done with the $_GET. You need a controller with a method that processes the URL: Code: Color extends Controller So then you call http://localhost/projectName/index.php/c.../red/rough to use it.
[eluser]pistolPete[/eluser]
I'd rather use this: Code: Color extends Controller User guide
[eluser]mjo1337[/eluser]
How do i get the form values into the URL segments to start with?
[eluser]tokyotech[/eluser]
[quote author="pistolPete" date="1252195486"]I'd rather use this: Code: Color extends Controller User guide[/quote] So this puts the URI segements into the parameters? Interesting. I never knew that! Definitely more traditional style programming and easier for other people to read your code.
[eluser]tokyotech[/eluser]
[quote author="mjo1337" date="1252196791"]How do i get the form values into the URL segments to start with?[/quote] Using GET for forms is quite awkward, but if you insist: Code: $this->load->helper('url');
[eluser]mjo1337[/eluser]
Suppose I could do it this way? POST from the form to begin with then add those values to the navigation links so 'next' would be Code: '<a href="/search/' . $clr . '/' . $size . '/' . $txtr . '">Next</a>'; I could check to see if POST values are present, use those, otherwise use URI segments. |
Welcome Guest, Not a member yet? Register Sign In |