Welcome Guest, Not a member yet? Register   Sign In
How to Convert Form Get Method (Query String) URI into Segment URI
#1

[eluser]andrew nevins[/eluser]
Hi all,

I've been searching for a while on Google, but have only found how to enable Query Strings http://www.askaboutphp.com/58/codeignite...rings.html .

I have a form that uses a GET method and produces this URI,
Code:
books/course?course_id=CC100&format=XML&submit=Submit

I want to convert this URI to use Segments, just as a POST method would produce.
The ideal URI I would like is:
Code:
books/course/CC100/XML

Anyone know how I'd go about this?
#2

[eluser]jprateragg[/eluser]
Any particular reason why you would want to do this?

I'm still fairly new to CI, but you could have two functions in your Books controller--one that hosts the form, and another that displays the results using a redirect. You could have your form controller display the form submitting it via post, format the output to a segmented URI, then redirect to a second controller that just shows the results.
#3

[eluser]andrew nevins[/eluser]
The reason why I must use a GET method is it's part of the brief.
Quote:"Three main HTTP GET requests are required to be implemented. Each should be implemented as JSON and XML according to the URL of the request :-

A. Books by course

http://www.cems.uwe.ac.uk/~<yourusername...se-id>/xml
http://www.cems.uwe.ac.uk/~<yourusername...e-id>/json"
I'm using a post method for another form and it generates the correct URI structure, it's just a problem I'm experiencing with a GET method.
#4

[eluser]Aken[/eluser]
In my knowledge, there's two options: 1) change the action URL via Javascript 2) use an intermediary controller to process the GET request and redirect appropriately. Perhaps someone else has another solution that I'm unaware of.




Theme © iAndrew 2016 - Forum software by © MyBB