I got a movie search website but when I search something it says 404 page not found.
The site is working under a framework called code igniter.
Here is the back-end code of search engine:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Search extends CI_Controller {
function __construct() {
parent::__construct();
}
public function index($extra=array()) {
$q = $this->input->get('q');
if (!empty($q)) {
redirect('search/' . $q);
}
redirect();
}
public function do_search() {
$this->load->model('movies');
$this->load->model('ssearch');
$search_string = $this->uri->segment(2);
$data['main_menubar']['categories'] = $this->movies->get_all_categories();
$data['search']['results'] = $this->ssearch->search_for_movies($search_string);
echo $this->load->view('includes/header', (isset($data['header']) ? $data['header'] : ''), true);
echo $this->load->view('includes/main_menubar', (isset($data['main_menubar']) ? $data['main_menubar'] : ''), true);
echo $this->load->view('search', (isset($data['search']) ? $data['search'] : ''), true);
echo $this->load->view('includes/footer', (isset($data['footer']) ? $data['footer'] : ''), true);
}
}
And the front-end code:
<div class="content_segment recentMovies clearfix">
<div class="segment_title clearfix">
Search: <?php echo urldecode($this->uri->segment(2)); ?>
</div> <!-- segment_title -->
<div class="inner_padding clearfix">
<div class="horisontal_movie_list clearfix">
<?php if(empty($results)) : ?>
<p>No movies found.</p>
<?php endif; ?>
<ul>
<?php if(!empty($results)): ?>
<?php foreach($results as $movie) : ?>
<?php
$categories = explode(',', $movie['categories']);
$cat_ids = explode(',', $movie['categories_id']);
$movie['categories'] = "";
for ($i=0; $i < count($categories); ++$i) {
$movie['categories'] .= '<a href="'.site_url('view/category/'. $cat_ids[$i]).'">'.$categories[$i].'</a>, ';
}
$movie['categories'] = substr($movie['categories'], 0, -2);
?>
<li>
<a href="<?php echo site_url('view/movie/'. $movie['id']); ?>">
<div class="imageWrapper">
<img src="<?php echo base_url() . 'img/movie_covers/' . $movie['cover_image']; ?>" alt="No cover!" />
</div>
</a>
<div class="information">
<h4 class="title"> <?php if($movie['favorite'] == 1) : ?><img src="<?php echo base_url(); ?>img/other/favorite_icon_small.png" alt="" /><?php endif; ?> <a href="<?php echo site_url('view/movie/'. $movie['id']); ?>"> <?php echo $movie['movie_title']; ?> </a> </h4>
<p class="meta"><?php echo $movie['categories']; ?> | <?php echo $movie['release_date']; ?> | First watched <?php echo date('F j, Y', $movie['watch_date']); ?></p>
<p class="description"><?php echo $movie['description']; ?></p>
</div>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</div> <!-- list -->
</div> <!-- content_segment -->
And the search bar code in the menu bar:
<menu class="menubar clearfix">
<a class="logo" href="<?php echo site_url(); ?>"></a>
<ul class="clearfix">
<li> <a href="<?php echo site_url() ?>"> Home </a> </li>
<li> <a href="<?php echo site_url('view/movies'); ?>"> Movies </a> </li>
<li class="categories_link">
<a href="<?php echo site_url('view/category') ?>"> Categories </a>
<ul>
<?php foreach ($categories as $cat) : ?>
<li><a href="<?php echo site_url('view/category/' . $cat['id']); ?>"><?php echo $cat['name']; ?></a></li>
<?php endforeach; ?>
</ul>
</li>
<li> <a href="<?php echo site_url('admin') ?>"> Admin area </a> </li>
</ul>
<div class="search">
<form action="<?php echo site_url('search'); ?>" method="GET">
<input type="search" name="q" value="" autofocus placeholder="Search" />
</form>
</div>
</menu>
I hope somebody finds a solution, I am stuck for 2 days.
Thanks.