little help with redirecting logic |
[eluser]knucklehead[/eluser]
Hello! I am trying to create a codeigniter app but have some small problems with redirecting... What I've created so far is a 'main' page with a form where you choose one of items from dropdown menu. Form is submitted via POST method, and on next page user should be able to modify that item's data (let's call this 'item' page). Data on 'item' page is strictly dependent on POST data. Then, I try to create some add/edit/delete item controllers but I have a problem with redirecting to the item's page after adding, editing or deleting items. So... I guide user through few steps, and after last step I should redirect to 'item' page (which is relying on POST data) but I'm not sure how to send POST data back again... If it is relevant in any case, I'm using 'Most simple template engine' in my app to show all the data... (http://maestric.com/doc/php/codeigniter_template) Hope I didn't complicated too much with my explanations Thanks for any help in advance!
[eluser]sketchynix[/eluser]
Could you post some code or provide a link for your problem? The problem seems solvable, but it is rather vague right now and any answer provided would likely be just as vague without some code to work with
[eluser]knucklehead[/eluser]
Hey sketchynix, thanks for help, I will try to summarize my code in a few words First, I set up template system, and in each controller i am sending some data to my template; Code: <?php So, in my Main view, I am showing the shows list and user selects one and goes to Insert controller: Code: <?php Here user can modify data within a 'show'... Let's say the user wants to delete some item from the list, he clicks on a delete button and my Delete controller looks like this: Code: <?php And I'm stuck here... I don't understand how to send data back to Insert controller because he expects that I send some form, right? Thanks for help! Cheers!
[eluser]SPeed_FANat1c[/eluser]
Not sure if it will help but I think you can make a parameter to your index function in Insert controller and pass some data. And before the line $get_items = $this->items_model->get_items_for_show($_POST['show']); check if index function has data (not default data) in parameter, if it hasn't then use data from $_POST. for example your index function would be Code: function index ($var = 'default')
[eluser]kaejiavo[/eluser]
On your form put the Show ID in a hidden field. Then you can redirect to Insert/index/Show_id Change your Insert/index method to Code: function index($show_id = 0) { This should maybe work, but i would strongly suggest you to read the user_guide Form_validation_Class, Input_And_Security_Class... I am not even sure if you can access the POST values in CI with $_POST['value']. Marco
[eluser]knucklehead[/eluser]
Hello guys and thanks for helping me with this one I had an idea to change my index function like you said, but the problem is that I should send more than only 'show_id' back to my Insert controller... I'm thinking to somehow send a variable which will hold all the data from Insert controller, through all steps and in last step I will just pass it back to Insert controller... Do you think that's a good idea? @mawi27 Ah yes, I know about Input class etc, but I had some small problems with it, so I accidentally left $_POST lines... I will fix that right now Thanks one more time
[eluser]kaejiavo[/eluser]
I think it is no good idea. You should only transfer the id and get all related data from the database. Think of the situation that some guy has tamper data installed as firefox extension (we as developers all have it, for sure). He looks at your form with this huge POST array and thinks - now, i would like to see what the app makes of this obscure input... You would have to sanitize and validate each of your POST array fields to make this working. I would definitely not do that. Marco
[eluser]knucklehead[/eluser]
Hmmm, interesting Ok, I will try to redesign my app a bit, so I could easily fetch all the data I need in both cases; if user selects a show at the very beginning, or after redirecting back to Input controller from any other page... I think that would be the best thing to do in my case, right?
[eluser]kaejiavo[/eluser]
a little example: Code: function edit($id = 0) {
|
Welcome Guest, Not a member yet? Register Sign In |