Contact Form - Help? |
[eluser]ceneb[/eluser]
I'm pretty stuck at a small hurdle and would appreciate any help. Basically, I'm trying to create a contact form using CI. This is it at the moment: http://www.ceneb.com/index.php/contact It seems to work but I don't see how it sends to me. My current code is on the view: Code: <div id="main-content"> and on the controller: Code: <?php Thanks in advance, Peter
[eluser]Kromack[/eluser]
Rather than to only load the success view, you also have to send the email that will list all form post data. For exemple : http://ellislab.com/codeigniter/user-gui...email.html Code: $this->load->library('email'); Good luck
[eluser]ceneb[/eluser]
Thanks for your reply. I looked at that documentation before and I though perhaps I just needed to add $this->email->to('[email protected]'); to the controller but it gave an error. I think it's going to take me some time to get used to CI. I've added: Quote:$this->load->library('email'); to it now and it does now send but the subject doesnt change nor does the senders email and it seems to send out twice. This is the code now: Code: <?php EDIT: forgot to add it has additional text in the top right of the page. Thanks!
[eluser]summery[/eluser]
Hi Ceneb, Maybe you are receiving the email multiple times because you have the same email address in the to:, cc: and bcc: fields? About the subject not changing, have you tried changing this line of code: Code: $this->email->subject('Email Test'); to something like: Code: $this->email->subject('This is my new subject line'); Hope this helps, good luck!
[eluser]ceneb[/eluser]
What I need is the subject and email etc to be what the user fills out in the contact form if that makes sense. Thanks, Peter
[eluser]Twisted1919[/eluser]
Your problem is your constructor . in the constructor just load the email and the form-validation library . The rest of the logic goes to your method . In the way you posted , an email is send everytime when the contact page is accessed, even if the form validation fails or not .
[eluser]summery[/eluser]
Oh, of course. Your initial form includes the following fields: name, email, comments. Since the user isn't entering a subject line, just use a generic one in your email. Try: Code: $this->email->subject('New website comment'); |
Welcome Guest, Not a member yet? Register Sign In |