[eluser]ebuoe[/eluser]
/////this is a section of the code that is suppose to allow you to you to upload images alongside your ad///////
session_start();
$data['cap_value']=$_SESSION["captcha"];
$cap=$_SESSION["captcha"];
$this->load->library('form_validation');
$this->form_validation->set_rules('lname', 'Last name', 'trim|required|alpha_dash');
$this->form_validation->set_rules('fname', 'First name', 'trim|required|alpha_dash');
$this->form_validation->set_rules('group', 'Group', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required');
$this->form_validation->set_rules('phone', 'Phone ', 'required');
$this->form_validation->set_rules('detail', 'Detail', 'trim|required');
/////////////this part handles form captcha validation//////////////////////////////////////////////////////////////////////////////
$captcha_image=$this->input->post('captcha_confirm');//this returns the captcha value
if($cap!=$captcha_image)
{
$this->form_validation->set_rules('captcha_confirm', 'correct value for this', 'trim|required|exact_length[6]|matches[captcha_image]');
}
////////////////////////////////////////this ends captcha form validation
if ($this->form_validation->run() == FALSE)
{
$this->load->view('adverts_view',$data);
}
else
{
if($cap==$captcha_image)
{
$lname=$this->input->post('lname');
$fname=$this->input->post('fname');
$group=$this->input->post('group');
$email=$this->input->post('email');
$web=$this->input->post('website');
$phone=$this->input->post('phone');
$detail=$this->input->post('detail');
$config['upload_path'] = './adverts/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
//////end of succesful upload//////
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
}
else
{ $error = array('error' => 'Sucessfully uploaded');
$data = array('upload_data' => $this->upload->data());
$picture=$this->upload->data();
////$this->upload->data contains the array of the file property and it is needed for upload/////////
$image="adverts/".$picture['file_name'];
}
$this->access->advert_user($lname,$fname,$group,$email,$web,$phone,$image,$detail);
}
session_destroy();
header('Location: ' . site_url('/home/adverts'));
}