I have a html form that his action is for “exmaple.com/mail.php?name=dan” for example.
How can I pass this parameter to Codeigniter’s controller?
the ‘action’ in codeigniter is going to – example.com/mail, can’t I do exmaple.com/mail?name=dan, right? so what can I do? (And.. I can’t use Ajax for this :-))
There are several solutions. You can do it like this
$name=$this->input->get("name"), but if you want to preserve the Codeigniter’s philosophy you can use Javascript to change the action url of the form to /mail/dan. In that case you can access the data with this:$name=$this->uri->segment($number). $number in your case is 2, becouse “dan” is in the second URI’s segment.NOTE: If you use the second aproach, keep in mind that codeigniter’s default behaviour is to automatically call controller/method from first and second segment of URI. (http://domain.com/controller/method ) In order to prevent this behaviour you can edit application/config/routes.php file. For detailed instructions refer to oficial guide.