CodeIgniter Forums
Sending post data? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Sending post data? (/showthread.php?tid=6053)



Sending post data? - El Forum - 02-13-2008

[eluser]agartzia[/eluser]
Hi!

I was trying to figure out which way is the best to send post data to a controller from a link?

For example, when I click in a "Search all post by user XXX" and it takes me to a search results page.

I've thought of Javascript, but it's somehow a "tricky" solution.

Cheers!


Sending post data? - El Forum - 02-13-2008

[eluser]xwero[/eluser]
I don't think you want to send post data using a $_GET request Smile

I think you want to build a link that gets the data: http://site.com/user/1/posts or http://site.com/posts/user/1. take a look at the forum links for inspiration (my forum posts).


Sending post data? - El Forum - 02-13-2008

[eluser]agartzia[/eluser]
[quote author="xwero" date="1202931656"]I don't think you want to send post data using a $_GET request Smile

I think you want to build a link that gets the data: http://site.com/user/1/posts or http://site.com/posts/user/1. take a look at the forum links for inspiration (my forum posts).[/quote]

xwero, as fast as always!

Yep, I want to do a search from a link. I've done a function...

Code:
class Search extends Controller {

    function redirect($controller = 'of', $field = '', $value = '')
    {
            //"magic unexistent function"
            redirect_to($controller, $field, $value);

    }

}

I could code some Javascript, but as I've said, it's not 'clean' enough.

The forum is a good example, as well.


Sending post data? - El Forum - 02-13-2008

[eluser]xwero[/eluser]
I'm not sure why you want to redirect your search?

If you have input fields you want to send along with the link you are better of with a form than you can send whatever you want.


Sending post data? - El Forum - 02-13-2008

[eluser]Negligence[/eluser]
Save it to the session, then redirect.


Sending post data? - El Forum - 02-14-2008

[eluser]agartzia[/eluser]
[quote author="Negligence" date="1202942226"]Save it to the session, then redirect.[/quote]

Hey, that's a good idea... I'll have to modify some of the code, but it's ok.

Thanks!