Disclaimer: I'm new to web develoment.
Scenario: I've created a contact form, and I'm trying to pass the input into the email class functions used in CodeIgniter. I am receiving undefined variable errors when the form is submitted. Email library is autoloaded for reference. It's late, and I may be overlooking something easy, but it doesn't hurt to post. Thanks a lot for all of your help!
Controller:
public function index()
{
//form validation
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
$this->form_validation->set_rules('subject', 'Subject', 'required');
$this->form_validation->set_rules('message', 'Message', 'required');
$this->data['email'] = array(
'name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email'),
);
$this->data['subject'] = array(
'name' => 'subject',
'id' => 'subject',
'type' => 'text',
'value' => $this->form_validation->set_value('subject'),
);
$this->data['message'] = array(
'name' => 'message',
'id' => 'message',
'type' => 'text',
'value' => $this->form_validation->set_value('message'),
);
if ($this->form_validation->run() == true)
{
$this->email->from($email);
$this->email->to('support#example.com');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
redirect('contact/success');
}
else
{
$this->data['error_message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('error_message');
$title['title'] = 'Contact';
$this->load->view('public/head_view', $title);
$this->load->view('public/header_view');
$this->load->view('public/contact_view', $this->data);
$this->load->view('public/footer_view');
}
View:
<div id="infoMessage"><?php echo $error_message;?></div>
<?php $attritubes = array('class' => 'nice'); ?>
<?php echo form_open('contact'); ?>
<p>Email Address:<br />
<?php echo form_input($email); ?>
</p>
<p>Subject:<br />
<?php echo form_input($subject); ?>
</p>
<p>Message:<br />
<?php echo form_textarea($message); ?>
</p>
<p><?php echo form_submit('submit', 'Submit'); ?></p>
<?php echo form_close(); ?>
Well, you barely define any variable here:
if ($this->form_validation->run() == true)
{
$this->email->from($email);
$this->email->to('support#example.com');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
redirect('contact/success');
}
Where do $email, $subject, $message come from?
You might want to use something like (but I suggest you do better :))
$email = $this->input->post('email');
$subject = $this->input->post('subject');
$message = $this->input->post('message');
Also, make sure you've loaded the email library before calling it, and that you load the view in your else{} part (since you omitted it I cannot tell)
Related
I'm working on a comment section for my blog post in CodeIgniter, I based myself on a tutorial by Brad Traversy and I followed each step carefully but somehow it does not work within my template.
This is show method in my Post Controller:
public function show($slug)
{
// Get Posts by Slug
$data['posts'] = $this->Post_model->get_by_slug($slug);
// Get Comments per Post
$post_id = $data['posts']['id']; // Here is where I get the error
$data['comments'] = $this->Post_model->get_comments($post_id);
// If empty show a 404 error
if(empty($data['posts'])){
show_404();
}
// Load template
$this->template->load('public', 'default', 'posts/show', $data);
}
I created a variable $post_id in order to get the comments for the current post that is being visited by an user. All this should come from my Post_model:
public function get_comments($post_id){
$this->db->select('username,email,website,body');
$this->db->from('comments');
$query = $this->db->get_where('comments', array('post_id' => $post_id));
return $query->result_array();
}
This is where I'm creating the form to add the comment:
<!-- Form -->
<h4>Add a comment</h4>
<?php echo validation_errors('<p class="alert alert-danger">'); ?>
<?php echo form_open('public/comments/add_post_comment/'.$post['id']); ?>
<!-- Username -->
<div class="form-group">
<?php echo form_label('Username', 'username'); ?>
<?php
$data = array(
'id' => 'username',
'name' => 'username',
'class' => 'form-control',
'placeholder' => 'John Doe',
'value' => set_value('username')
);
?>
<?php echo form_input($data) ?>
</div>
<!-- Email -->
<div class="form-group">
<?php echo form_label('E-mail', 'email'); ?>
<?php
$data = array(
'id' => 'email',
'name' => 'email',
'class' => 'form-control',
'placeholder' => 'JohnDoe#demo.com',
'value' => set_value('email')
);
?>
<?php echo form_input($data) ?>
</div>
<!-- Website -->
<div class="form-group">
<?php echo form_label('Website', 'website'); ?>
<?php
$data = array(
'id' => 'website',
'name' => 'website',
'class' => 'form-control',
'placeholder' => 'https://www.example.com',
'value' => set_value('website')
);
?>
<?php echo form_input($data) ?>
</div>
<!-- Comments Body -->
<div class="form-group">
<?php echo form_label('Body', 'body'); ?>
<?php
$data = array(
'id' => 'body',
'name' => 'body',
'class' => 'form-control',
'placeholder' => 'Write here',
'value' => set_value('body')
);
?>
<?php echo form_textarea($data); ?>
</div>
<!-- Hidden Input -->
<?php
$data = array(
'name' => 'slug',
'value' => $posts->slug,
);
?>
<?php echo form_hidden($data); ?>
<!-- Submit Button -->
<?php echo form_submit('mysubmit', 'Add Comment', array('class' => 'btn btn-primary')); ?>
<?php echo form_close(); ?>
<?php endif; ?>
This is the Controller I'm using to add comments to the specific $post_id:
public function add_post_comment($post_id)
{
// Field Rules
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[3]');
$this->form_validation->set_rules('body', 'Body', 'trim|required|min_length[3]');
if ($this->form_validation->run() == FALSE) {
// Set Message
$this->session->set_flashdata('error', 'There was an error in proccessing the comment. Please, try again.');
// Redirect to current page
redirect(site_url() . 'posts/show/'.$post_id);
} else {
// Get Post by Slug
$slug = $this->input->post('slug');
$data['posts'] = $this->Post_model->get_by_slug($slug);
// Create Post Array
$data = array(
'post_id' => $post_id,
'username' => $this->input->post('username'),
'user_id' => $this->session->userdata('user_id'),
'email' => $this->input->post('email'),
'website' => $this->input->post('website'),
'body' => $this->input->post('body'),
);
// Insert Comments
$this->Comments_model->add($data);
// Set Message
$this->session->set_flashdata('success', 'Your comment has been posted');
// Redirect to same page if form was not successful or submitted
redirect(site_url() . 'posts/show/'.$post_id);
}
}
All this should work according to some tutorials that I have seen before but this time is not.
The error comes from my function show. Any idea on how to fix this?
Thanks for helping.
Ok well as you would have read in the codeigniter users guide - $query->row() will return an object.
So you would use $data['posts']->id. Which may or may not work with your current PHP Version. I'm open to be corrected on that point.
If you want an associative array, as you are attempting to use, then you would use $query->row_array();
If you had performed a var_dump like...
public function show($slug)
{
// Get Posts by Slug
$data['posts'] = $this->Post_model->get_by_slug($slug);
// Quick Debug to Eyeball what is actually being returned.
var_dump($data['posts']);
exit();
// Get Comments per Post
$post_id = $data['posts']['id']; // Here is where I get the error
$data['comments'] = $this->Post_model->get_comments($post_id);
// If empty show a 404 error
if(empty($data['posts'])){
show_404();
}
// Load template
$this->template->load('public', 'default', 'posts/show', $data);
}
You would see ( and its always a good check when validating your code ) what is being returned by $this->Post_model->get_by_slug($slug);
It's a very good idea to know how to "look" at what your variables are and check they are what you think they should be.
I am currently doing a project. I have a checkbox( where the user will choose type of services provided by the company). When I try to post the service that was selected(for example 2 services is checked) in my controller, I am only getting one service. The question is how can I get the multiple values in my checkbox?
Note: I also tried to use foreach within my controller, I am getting some error like "Invalid argument supplied for foreach()".
View
<label>Desired Service</label> <br>
<?php foreach($services as $s):?>
<label><input type="checkbox" name="service_name[]" value="<?= $s->service_name?>"><?= $s->service_name?></label>
<br>
<?php endforeach?>
Controller
$this->form_validation->set_error_delimiters('<div class="alert alert-danger" role="alert">', '</div>');
$this->form_validation->set_rules('full_name', 'Fullname', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('contact', 'Contact', 'required');
$this->form_validation->set_rules('date', 'Date', 'required');
$this->form_validation->set_rules('address', 'Address', 'required');
$this->form_validation->set_rules('zip_code', 'Zip Code', 'numeric|required');
$this->form_validation->set_rules('province', 'Province', 'required');
$this->form_validation->set_rules('date', 'Date', 'required');
$this->form_validation->set_rules('service_name', 'Service', 'required');
if ($this->form_validation->run() == FALSE) {
$this->index();
}
else {
$service_name = implode(', ', $_POST['service_name']);
$event = array(
'full_name' => $this->input->post('full_name'),
'email' => $this->input->post('email'),
'contact' => $this->input->post('contact'),
'address' => $this->input->post('address'),
'zip_code' => $this->input->post('zip_code'),
'state_province' => $this->input->post('province'),
'date' => $this->input->post('date'),
'service' => $service_name
);
$this->EventModel->add_event($event);
echo "<script>
window.alert('Your Desired Date is being Proccessed!');
location.href = '".site_url('/')."';
</script>";
}
Change from
$service_name = $_POST['service_name'];
foreach($service_name as $key =>$value)
{
echo $value;
}
die;
to
$service_name = implode(',',$_POST['service_name']);
echo $service_name;
I hope it will solve your problem
if (!empty($this->input->post('service_name'))) {
foreach ($this->input->post('service_name') as $key => $val) {
$data[] = array(
'service_name' => $_POST['service_name'][$key]
);
}
foreach ($data as $item) {
echo $item['service_name'];
}
Try:
$service_name = $this->input->post('service_name');
for($i=0;$i < count($service_name);$i++){
echo $service_name[$i];
}
I wrote an function to send an email to the user using the email they put on their registration form. However while testing it the email does not go to the email address entered. I checked to make sure that the function was working by having the email cc to an address, which worked. Below is the function.
View
<div class="col-lg-4 col-lg-offset-4">
<h2>Hello There</h2>
<h5>Please enter the required information below.</h5>
<?php
$fattr = array('class' => 'form-signin');
echo form_open('/main/register', $fattr); ?>
<div class="form-group">
<?php echo form_input(array('name'=>'firstname', 'id'=> 'firstname', 'placeholder'=>'First Name', 'class'=>'form-control', 'value' => set_value('firstname'))); ?>
<?php echo form_error('firstname');?>
</div>
<div class="form-group">
<?php echo form_input(array('name'=>'lastname', 'id'=> 'lastname', 'placeholder'=>'Last Name', 'class'=>'form-control', 'value'=> set_value('lastname'))); ?>
<?php echo form_error('lastname');?>
</div>
<div class="form-group">
<?php echo form_input(array('name'=>'email', 'id'=> 'email', 'placeholder'=>'Email', 'class'=>'form-control', 'value'=> set_value('email'))); ?>
<?php echo form_error('email');?>
</div>
<?php echo form_submit(array('value'=>'Sign up', 'class'=>'btn btn-lg btn-primary btn-block')); ?>
<?php echo form_close(); ?>
</div>
Controller
public function register()
{
$this->form_validation->set_rules('firstname', 'First Name', 'required');
$this->form_validation->set_rules('lastname', 'Last Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if ($this->form_validation->run() == FALSE) {
$this->load->view('header');
$this->load->view('register');
$this->load->view('footer');
}else{
if($this->user_model->isDuplicate($this->input->post('email'))){
$this->session->set_flashdata('flash_message', 'User email already exists');
redirect(site_url().'main/login');
}else{
$clean = $this->security->xss_clean($this->input->post(NULL, TRUE));
$id = $this->user_model->insertUser($clean);
$token = $this->user_model->insertToken($id);
$qstring = base64_encode($token);
$url = site_url() . 'main/complete/token/' . $qstring;
$link = '' . $url . '';
$message = '';
$message .= '<strong>You have signed up with our website</strong><br>';
$message .= '<strong>Please click:</strong> ' . $link;
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'host',
'smtp_port' => 'port',
'smtp_user' => 'username',
'smtp_pass' => 'password');
$this->load->library('email', $config);
$this->email->set_newline("/r/n");
$this->email->from('***#****.com', 'High Ball Run8');
$this->email->to(set_value("email"));
$this->email->cc('****#*****.com');
$this->email->subject('Highball Registration Email Activation');
$this->email->message($message);
if ($this->email->send()) {
redirect(site_url());
}else{
show_error($this->email->print_debugger());
}
exit;
Have you tried
var_dump(set_value("email")); exit();
To see what the output is? Chances are you are not getting the to address correctly, if the hardcoded CC works.
Please check following working code
function sendMail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx#gmail.com', // change it to yours
'smtp_pass' => 'xxx', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = '';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxx#gmail.com'); // change it to yours
$this->email->to('xxx#gmail.com');// change it to yours
$this->email->subject('Resume from JobsBuddy for your Job posting');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
Reference
I am using Ionauth library in codeigniter and edited edit_user() method in Auth controller to enable individual user updating his/her own user settings. So when a logged in user goes to : siteurl/auth/edit_user it shows the user settings just fine. But when I hit the save button I got an error: "This form post did not pass our security checks". Though the default url (siteurl/auth/edit_user/userID) works fine, For individual non-admin user I want to keep the url without userID at the end.
here is my edit_user() method:
//edit a user
function edit_user($id=NULL)
{
$this->data['title'] = "Edit User";
if (!$this->ion_auth->logged_in() || (!$this->ion_auth->is_admin() && !($this->ion_auth->user()->row()->id == $id) && !($id==NULL )))
//if (!$this->ionauth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth', 'refresh');
}
if($id==NULL){
$user = $this->ion_auth->user()->row();
}else{
$user = $this->ion_auth->user($id)->row();
}
$groups=$this->ion_auth->groups()->result_array();
$currentGroups = $this->ion_auth->get_users_groups($id)->result();
//process the phone number
/**if (isset($user->phone) && !empty($user->phone))
{
$user->phone = explode('-', $user->phone);
} **/
//validate form input
$this->form_validation->set_rules('first_name', $this->lang->line('edit_user_validation_fname_label'), 'required|xss_clean');
$this->form_validation->set_rules('last_name', $this->lang->line('edit_user_validation_lname_label'), 'required|xss_clean');
if(!($this->input->post('email')==$user->email)){
$this->form_validation->set_rules('email', $this->lang->line('edit_user_validation_email_label'), 'required|valid_email|is_unique[users.email]');
}else{
$this->form_validation->set_rules('email', $this->lang->line('edit_user_validation_email_label'), 'required|valid_email');
}
/** $this->form_validation->set_rules('phone2', $this->lang->line('edit_user_validation_phone2_label'), 'required|xss_clean|min_length[3]|max_length[3]');
$this->form_validation->set_rules('phone3', $this->lang->line('edit_user_validation_phone3_label'), 'required|xss_clean|min_length[4]|max_length[4]');
$this->form_validation->set_rules('company', $this->lang->line('edit_user_validation_company_label'), 'required|xss_clean'); **/
$this->form_validation->set_rules('groups', $this->lang->line('edit_user_validation_groups_label'), 'xss_clean');
//$this->form_validation->set_message('is_unique[users.email]','Email already exists or Invalid');
if (isset($_POST) && !empty($_POST))
{
// do we have a valid request?
if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id'))
{
show_error($this->lang->line('error_csrf'));
}
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
/** 'phone' => $this->input->post('phone1') . '-' . $this->input->post('phone2') . '-' . $this->input->post('phone3'), **/
);
//if($this->ion_auth->is_admin()){
//Update the groups user belongs to
$groupData = $this->input->post('groups');
if (isset($groupData) && !empty($groupData)) {
$this->ion_auth->remove_from_group('', $id);
foreach ($groupData as $grp) {
$this->ion_auth->add_to_group($grp, $id);
}
}
//}
//update the password if it was posted
if ($this->input->post('password'))
{
$this->form_validation->set_rules('password', $this->lang->line('edit_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
$this->form_validation->set_rules('password_confirm', $this->lang->line('edit_user_validation_password_confirm_label'), 'required');
$data['password'] = $this->input->post('password');
}
if ($this->form_validation->run() === TRUE)
{
$this->ion_auth->update($user->id, $data);
//check to see if we are creating the user
//redirect them back to the admin page
$this->session->set_flashdata('message', "User Saved");
redirect("auth", 'refresh');
}
}
//display the edit user form
$this->data['csrf'] = $this->_get_csrf_nonce();
//set the flash data error message if there is one
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
//pass the user to the view
$this->data['user'] = $user;
//if($this->ion_auth->is_admin()){
$this->data['groups'] = $groups;
$this->data['currentGroups'] = $currentGroups;
//}
$this->data['first_name'] = array(
'name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'value' => $this->form_validation->set_value('first_name', $user->first_name),
);
$this->data['last_name'] = array(
'name' => 'last_name',
'id' => 'last_name',
'type' => 'text',
'value' => $this->form_validation->set_value('last_name', $user->last_name),
);
$this->data['email'] = array(
'name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email', $user->email),
);
/** $this->data['phone1'] = array(
'name' => 'phone1',
'id' => 'phone1',
'type' => 'text',
'value' => $this->form_validation->set_value('phone1', $user->phone[0]),
);
$this->data['phone2'] = array(
'name' => 'phone2',
'id' => 'phone2',
'type' => 'text',
'value' => $this->form_validation->set_value('phone2', $user->phone[1]),
);
$this->data['phone3'] = array(
'name' => 'phone3',
'id' => 'phone3',
'type' => 'text',
'value' => $this->form_validation->set_value('phone3', $user->phone[2]),
); **/
$this->data['password'] = array(
'name' => 'password',
'id' => 'password',
'type' => 'password'
);
$this->data['password_confirm'] = array(
'name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password'
);
$this->load->view('header');
$this->_render_page('auth/edit_user', $this->data);
$this->load->view('footer');
}
and this is my view file (edit_user.php):
<h1><?php echo lang('edit_user_heading');?></h1>
<div id="body">
<p><?php echo lang('edit_user_subheading');?></p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open(uri_string());?>
<p>
<?php echo lang('edit_user_fname_label', 'first_name');?> <br />
<?php echo form_input($first_name);?>
</p>
<p>
<?php echo lang('edit_user_lname_label', 'last_name');?> <br />
<?php echo form_input($last_name);?>
</p>
<p>
<?php echo lang('edit_user_email_label', 'email');?> <br />
<?php echo form_input($email);?>
</p>
<!--
<p>
<?php echo lang('edit_user_phone_label', 'phone');?> <br />
<?php echo form_input($phone1);?>-<?php echo form_input($phone2);?>-<?php echo form_input($phone3);?>
</p>
-->
<p>
<?php echo lang('edit_user_password_label', 'password');?> <br />
<?php echo form_input($password);?>
</p>
<p>
<?php echo lang('edit_user_password_confirm_label', 'password_confirm');?><br />
<?php echo form_input($password_confirm);?>
</p>
<?php //if($this->ion_auth->is_admin()){ ?>
<h3><?php echo lang('edit_user_groups_heading');?></h3>
<?php foreach ($groups as $group):?>
<label class="checkbox">
<?php
$gID=$group['id'];
$checked = null;
$item = null;
foreach($currentGroups as $grp) {
if ($gID == $grp->id) {
$checked= ' checked="checked"';
break;
}
}
?>
<input type="checkbox" name="groups[]" value="<?php echo $group['id'];?>"<?php echo $checked;?>>
<?php echo $group['name'];?>
</label>
<?php endforeach?>
<?php //} ?>
<?php echo form_hidden('id', $user->id);?>
<?php echo form_hidden($csrf); ?>
<p><?php echo form_submit('submit', lang('edit_user_submit_btn'));?></p>
<?php echo form_close();?>
The csrf check is failing.
Try taking out $id = NULL in the method declaration (you don't need it anyway if you're sending the id via POST). Or explicitly set $id = $this->input->post('id'); before doing the csrf check.
In my case I was using relative URLs for the images and css files used in the site. Using base_url() to all the URLs present in the site fixed the problem. No issue now.
I'm trying to use the recaptcha with CodeIgniter. I followed some online instructions and finally I have done with only one step, just to pass the recaptcha to the view, but I can't validate the user input.
Here is my controller:
function download_application()
{
//load the libraries
$this->load->library('form_validation');
$this->load->library('recaptcha');
$this->lang->load('recaptcha');
//common data
$data['title'] = $_POST['application_name'];
$data['header'] = $_POST['application_name'];
$data['sub_header'] = 'تحميل استمارة قبول المشروع';
$data['title'] = $_POST['application_name'];
$data['recaptcha'] = $this->recaptcha->get_html();
//form validation
$this->form_validation->set_error_delimiters('<span class="notification">', '</span>');
$this->form_validation->set_message('required', 'هذا الحقل مطلوب ولا يمكن تجاهله');
$this->form_validation->set_rules('name', 'لابد من ادخال اسمك بالكامل', 'required');
$this->form_validation->set_rules('email', 'لابد من ادخال بريدك الالكترونى', 'required|email');
$this->form_validation->set_rules('country', 'لابد من ادخال بلدك', 'required');
$this->form_validation->set_rules('phone', 'لابد من ادخال رقم تليفونك', 'required');
//form submitted
if($this->input->post('recaptchasubmit')){
if($this->form_validation->run() == FALSE)
{
$this->load->view('header', $data);
$this->load->view('download', $data);
$this->load->view('footer', $data);
}
else
{
$this->load->view('header', $data);
$this->load->view('download', $data);
$this->load->view('footer', $data);
}
}
else{
$this->load->view('header', $data);
$this->load->view('download', $data);
$this->load->view('footer', $data);
}
}
and here is my view
<?php
$form_attributes = array(
'class' => 'form'
);
$btn_download = array(
'type' => 'image',
'src' => base_url().'images/download.gif',
'name' => 'recaptchasubmit',
'width' => '103',
'height' => '33',
'value' => 'تحميل'
);
$name = array(
'type' => 'text',
'name' => 'name',
'id' => 'name',
'value' => set_value('title')
);
$email = array(
'type' => 'text',
'name' => 'email',
'id' => 'email',
'value' => set_value('email')
);
$country = array(
'type' => 'text',
'name' => 'country',
'id' => 'country',
'value' => set_value('country')
);
$phone = array(
'type' => 'text',
'name' => 'phone',
'id' => 'phone',
'value' => set_value('phone')
);
?>
<?php echo form_open($base_url . 'arabia/download_application', $form_attributes); ?>
<fieldset>
<div class="input_container">
<label class="required">الاسم بالكامل</label>
<div class="input"><?php echo form_input($name); ?></div>
<?php echo form_error('name'); ?>
</div>
<div class="input_container">
<label class="required">البريد الالكترونى</label>
<div class="input"><?php echo form_input($email); ?></div>
<?php echo form_error('email'); ?>
</div>
<div class="input_container">
<label class="required">البلد</label>
<div class="input"><?php echo form_input($country); ?></div>
<?php echo form_error('country'); ?>
</div>
<div class="input_container">
<label class="required">التليفون</label>
<div class="input"><?php echo form_input($phone); ?></div>
<?php echo form_error('phone'); ?>
</div>
<?php echo $recaptcha; ?>
<?php echo form_error('recaptcha_response_field'); ?>
<?php echo form_hidden('application_name', $title); ?>
<?php echo form_hidden('generated_id', $title); ?>
</fieldset>
<span class="download"><?php echo form_submit($btn_download);?></span>
<?php echo form_close();?>
What do you mean you can't validate the user input? What is happening when you submit the form? Where are you redirected? What do you see?
The only thing I can see from your question thus far is that you are passing
$data['recaptcha'] = $this->recaptcha->get_html();
regardless if validation passes or not - so you'll see the recaptcha letters/numbers box either way. You need to overwrite that if validation passes to something like:
$data['recaptcha'] = "validation passed";