Можете ли подсказать как решить дз урока 24 из курса codeigniter?

0

Не могу придумать как все это сделать, с примерами работать не получается, даже не знаю как подступиться. Ни вывод ошибки ввода пароля сделать не выходит ни страницу изменения фильмов, делал по аналогии с изменением новостей, но совершенно не работает и я не понимаю почему.

Вот код моей попытки сделать edit для фильмов, но я не думаю что в нем есть хоть что-то дельное.

public function edit($slug = NULL) {
		$this->data['title'] = "Изменить страницу";
		$this->data['films_item'] = $this->news_model->getNews($slug);

		/*if(empty($this->data['films_item'])) {
			show_404();
		}

		if(!$this->dx_auth->is_admin()) {
			show_404();
		}*/

		$this->data['slug'] = $this->data['films_item']['slug'];
		$this->data['title'] = $this->data['films_item']['name'];
		$this->data['descriptions'] = $this->data['films_item']['descriptions'];
		$this->data['year'] = $this->data['films_item']['year'];
		$this->data['rating'] = $this->data['films_item']['rating'];
		$this->data['director'] = $this->data['films_item']['director'];
		$this->data['poster'] = $this->data['films_item']['poster'];
		$this->data['player_code'] = $this->data['films_item']['player_code'];
		$this->data['category_id'] = $this->data['films_item']['category_id'];

		if($this->input->post('slug') && $this->input->post('title') && $this->input->post('descriptions') && $this->input->post('year') && $this->input->post('rating') && $this->input->post('director') && $this->input->post('poster') && $this->input->post('player_code') && $this->input->post('category_id') ) {

			$slug = $this->input->post('slug');
			$title = $this->input->post('title');
			$descriptions = $this->input->post('descriptions');
			$year = $this->data['films_item']['year'];
			$rating = $this->data['films_item']['rating'];
			$director = $this->data['films_item']['director'];
			$poster = $this->data['films_item']['poster'];
			$player_code = $this->data['films_item']['player_code'];
			$category_id = $this->data['films_item']['category_id'];

			if($this->news_model->updatePage($slug, $title, $descriptions, $year, $rating, $director, $poster, $player_code, $category_id) ) {
				echo "Страница успешно изменена";
			}
		}

		$this->load->view('templates/header', $this->data);
		$this->load->view('movies/edit', $this->data);
		$this->load->view('templates/footer');

	}
php
codeigniter

2 ответов

2

В последнем уроке есть исходник, посмотрите как edit там реализован. 

+ у себя проверьте, что в строчке ниже (во view) вы все корректно post данные передаете, иначе внутри if код не выполнится и данные не сохранятся:

if($this->input->post('slug') && $this->input->post('title') && $this->input->post('descriptions') && $this->input->post('year') && $this->input->post('rating') && $this->input->post('director') && $this->input->post('poster') && $this->input->post('player_code') && $this->input->post('category_id') ) {

  

0

Большое спасибо!

Sign up or Log in to write an answer