Codeigniter - banner page choose file php errors |
I am new in CodeIgniter, I'm making an admin panel for all static pages, option is user click on choose file and select a file click to update banner and its uploaded and display on page but when i directly click on Update Banner button so it shows an php error, now i want to know two things first how I will rectify this error secondly is there any alert thing here so i mention the user to first upload file then click update banner button, please suggest i developerbook chatrandom already omegle provide php errors & coding of banner page.
A PHP Error was encountered Severity: Notice Message: Undefined variable: banner Filename: backend/inside_banner.php Line Number: 2 A PHP Error was encountered Severity: Notice Message: Undefined variable: page_id Filename: backend/inside_banner.php Line Number: 9 Code class Banner extends My_Controller { function __construct() { parent::__construct(); } public function index() { if ($this->input->post('submit')) { $upload_data = upload_file('banners', array('jpg|png|jpeg|gif'), '2028'); if ($upload_data['error_flag']) { $this->data['errors']['banner'] = $upload_data['errors']; $this->data['data'] = $_POST; $this->template->write_view('content', 'backend/banner_view', $this->data); $this->template->render(); } else { $posted_data = $_POST; $posted_data['file_name'] = $upload_data['upload_data']['file_name']; $posted_data['lang_id'] = $this->data['lang_id']; $b = new Banners(); $b->addBanner($posted_data); redirect('admin/banner'); } } $this->data['page_title'] = 'Add Banner'; $this->template->add_css('layout/css/form.css'); $this->data['allBanners'] = BannersTable::getAllBanners($this->data['lang_id']); $this->template->write_view('content', 'backend/banner_view', $this->data); $this->template->render(); } public function delete($banner_id) { $b = new Banners(); $b->deleteBanner($banner_id); redirect('admin/banner'); } public function inside($page_id) { if ($this->input->post('submit')) { $upload_data = upload_file('inside_banners', array('jpg|png|jpeg|gif'), '2028'); if ($upload_data['error_flag']) { $this->data['errors']['banner'] = $upload_data['errors']; $this->data['data'] = $_POST; $this->template->write_view('content', 'backend/inside_banner', $this->data); $this->template->render(); } else { $posted_data = $_POST; $posted_data['page_id'] = $page_id; $posted_data['file_name'] = $upload_data['upload_data']['file_name']; $posted_data['lang_id'] = $this->data['lang_id']; $ib = new InsideBanners(); $ib->addInsideBanner($posted_data); redirect('admin/banner/inside/' . $page_id); } } if ($page_id) { $this->data['page_title'] = 'Add ' . $page_id . ' Banner'; $this->template->add_css('layout/css/form.css'); $this->data['page_id'] = $page_id; $this->data['banner'] = InsideBannersTable::getOne($page_id); // var_dump($this->data['banner']);exit; $this->template->write_view('content', 'backend/inside_banner', $this->data); $this->template->render(); } else { redirect('admin/dashboard'); } } public function arrange(){ $b = new Banners(); $b->updateBannersOrder($_POST); redirect('admin/banner'); } } ?>
Your $b = new Banners(); will produce nothing, that's why $this->data is empty. You should read some tutorials about Codeigniter and MVC. You should create a Library (called Banner), and create a public function which will return an array containing your data.
|
Welcome Guest, Not a member yet? Register Sign In |