Formmail |
[eluser]europe72[/eluser]
Is there anything built into the CI framework similar to the age-old formmail.pl script? Meaning, what is the simplest method for posting a form and having its contents e-mailed? Like many things in PHP, this is not difficult to script w/o CI, but if there is something that makes this even easier I would like to know. Thanks.
[eluser]Derek Allard[/eluser]
You're on track in your last sentence. To do this I've always built the forum (you can use the form helper or build it yourself) and then use the email class to send stuff out. On darkhorse.to I do it like this Code: function index() And here is the view Code: <?php I've actually been wanting to make some additions... I'll do a blog entry about it in the near future if you want.
[eluser]ricklee[/eluser]
Derek, Thanks for the information. It's very helpful. I just tried this today though and I'm wondering how you go about setting authentication information for sending the email. I get this error (running on XAMPP): Code: A PHP Error was encountered And I dont' think you can put authentication information in php.ini, so how do you do this in CI? Thanks for any help! Rick
[eluser]Derek Allard[/eluser]
You can set config options for email right before you send it. Code: $config['protocol'] = 'smtp'; Another trick that I like to use is to create a file in application/config called "Email.php" and include it in there. Then it gets autoloaded, and no need for inititalize()? I'm writing up a tutorial about this - I'll try to remember to put it back here, but it'll be on my blog if you want to watch that.
[eluser]ricklee[/eluser]
That took care of it. Thanks! I'm still working on this form though and I have this other question. How do you get data from checkboxes? I have this for example: Code: <input type="checkbox" name="fruit[]" value ="apples" /> Apples But when I do this: $this->input->post('fruit'); It gives me a string (returning the last item selected) instead of an array. What am I doing wrong? Thanks for any tips! |
Welcome Guest, Not a member yet? Register Sign In |