Hi guys i'm creating a new project with codeigniter and bootstrap.
I've configurated the first page and CI is loading everything, but i got a problem with the contact form. If i try to use it without codeigniter is working good so i think the problem is in the controller.
that's my code: (that's the view) landing.php
<div class="col-md-8 col-md-offset-2">
<form action="%3C?php%20echo%20site_url('landing/index');%20?%3E" class=
"wow bounceInUp" data-wow-delay="0.2s" data-wow-offset="10" id=
"contact-form" method="post" name="contact-form" onsubmit=
"return checkform();">
<input name="act" type="hidden" value="act">
<div class="row">
<div class="col-md-6" style="margin-bottom:5px">
<input class="form-control input-lg" id="name" name="name"
placeholder="Name" required="required" type="text" value="name">
</div>
<div class="col-md-6" style="margin-bottom:5px">
<input class="form-control input-lg" id="email" name="email"
placeholder="E-mail" required="required" type="email" value="email">
</div>
</div>
<div class="row">
<div class="col-md-12" style="margin-bottom:5px">
<div class="form-group">
<input class="form-control input-lg" id="object" name="object"
placeholder="Object" required="required" type="text" value=
"object">
</div>
<div class="form-group" id="interested">
<select class="form-control input-lg" id="contact-form" name=
"interested">
<option value="select">
--Select--
</option>
<option id="info" value="info">
Info
</option>
<option id="careers" value="careers">
Careers
</option>
</select>
</div>
<div class="form-group" style="margin-bottom:5px">
<textarea class="form-control" name="message" rows="3">
</textarea>
</div><button class="btn btn-primary" style="width:100%;" type=
"submit">Send</button>
</div>
</div>
</form>
</div>
and this is the controller landing.php;
class Landing extends CI_Controller {
public function index(){
$this->load->view('header/landing.php');
$this->load->view('landing.php');
$this->load->view('footer/landing.php');
if(isset($_POST['act']) && $_POST['act'] =="act"){
$name = $_POST['name'];
$object = $_POST['object'];
$email = $_POST['email'];
$message = $_POST['message'];
$interested = $_POST['interested'];
if ($interested == 'info') {
$to = 'info@mymail.it';
}
else if ($interested == 'careers') {
$to = 'careers@mymail.it';
}
$this->load->library('email');
$this->email->from($email, $name);
$this->email->to($to);
$this->email->subject($object);
$this->email->message($message);
$this->email->send();
}
}
And this is the error showed when i try to send the mail:
An Error Was Encountered
The action you have requested is not allowed.
FIXED! the code was OK but i was passing the wrong variable in $this->email->to($interested); <- $interested go inside an if else and become $to ! that's why doesn't work! :D FIXED!