Welcome Guest, Not a member yet? Register   Sign In
Need Help Please Can Not Send Email From Website
#1

[eluser]razerone[/eluser]
Hi I am using email set up form my contact form I don't know what to put in my contact views form so people can send text emails with subject etc.. Just stuck on the views form side of things when I ad value it doesn't work not sure what doing wrong


contact controller

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contact extends MX_Controller {

function index() {

  $this->load->view('header');
  $this->load->view('contact');
  $this->load->view('footer');

}


function send() {

  $this->load->library('email');

  $this->email->set_newline("\r\n");

  $this->email->from('[email protected]', 'Website');
  $this->email->to('[email protected]');

  $this->email->subject('$subject');
  $this->email->message('$message');

  if($this->email->send()) {

   $this->load->view('header');
   $this->load->view('contact_sent');
   $this->load->view('footer');
  }
  else {
   show_error($this->email->print_debugger());
  }

}

}

contact views page

Code:
<form role="form" method="post" acti>
<div class="form-group">
<label for="name"></label>
&lt;input type="text" class="form-control" id="name" placeholder="Enter Name"&gt;
</div>
<div class="form-group">
<label for="email"></label>
&lt;input type="text" class="form-control" id="email" placeholder="Enter Email"&gt;
</div>
<div class="form-group">
<select  class="form-control" id="subject" name="subject">
<option value="na" selected="">Choose One:</option>
<option value="service">Feedback</option>
<option value="suggestions">Suggestion</option>
<option value="support">Question</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
&lt;textarea type="text" class="form-control" rows="4" placeholder="Message" name="message"&gt;&lt;/textarea>
</div>
<div id="success"> </div> &lt;!-- For success/fail messages --&gt;
<div class="pager">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
&lt;/form&gt;
#2

[eluser]Ckirk[/eluser]
Is this all your code or did you leave something out?
In your controller neither the index or the send functions are capturing the post data from the form ($this->input->post() ).

Check out Form Validation in the codeigniter manual for an example on how to capture your input.

#3

[eluser]razerone[/eluser]
I have another file that has my password and stuff on I have attached that

$this->load->library('email'); that has my protocol and that on it. I have placed that in my config folder it is better that way for security.

No just trying to get the front end done but hard understanding suitable code. for the inputs.
#4

[eluser]razerone[/eluser]
I got it all working now by reading properly through user guide

&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contactpage extends MX_Controller {

function index() {

$this->load->view('header');
$this->load->view('contact-us');
$this->load->view('footer');

$this->load->helper('form');

}

function messagesent() {
$this->load->helper('form');

$this->load->library('email');

$this->email->from($this->input->post('email'), $this->input->post('name'));
$this->email->to('demo@demo.com');

$this->email->subject($this->input->post('subject'));
$this->email->message($this->input->post('message'));

if($this->email->send()) {

$this->load->view('header');
$this->load->view('messagesent');
$this->load->view('footer');
}
else {
show_error($this->email->print_debugger());
}

}

}

&lt;?php echo form_open('/contactpage/messagesent'); ?&gt;
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
&lt;input name="name" type="text" id="focusedInput" class="form-control " placeholder="Enter Name"&gt;
</div>
<div class="form-group">
&lt;input name="email" type="text" id="focusedInput" class="form-control" placeholder="Enter Email"&gt;
</div>
<div class="form-group">
<select name="subject" id="focusedInput" class="form-control" >
<option selected="">Choose One:</option>
<option>Feedback</option>
<option>Suggestion</option>
<option>Question</option>
<option>Other</option>
</select>
</div>
<div class="form-group">
&lt;textarea name="message" type="text" class="form-control" rows="4" placeholder="Message" name="message"&gt;&lt;/textarea>
</div>
<div class="pager">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>

</div>
&lt;?php echo form_close();?&gt;
#5

[eluser]Ckirk[/eluser]
Glad you got it working Smile




Theme © iAndrew 2016 - Forum software by © MyBB