MrXortex Posted March 15, 2014 Share Posted March 15, 2014 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 --> The menu bar search: <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="search.php" value="" autofocus placeholder="Search" /> </form> </div> </menu> I hope someone finds a solution, I am stuck for 2 days. Cheers. Quote Link to comment Share on other sites More sharing options...
MrXortex Posted March 16, 2014 Author Share Posted March 16, 2014 Come on, anyone? Quote Link to comment Share on other sites More sharing options...
micah1701 Posted March 17, 2014 Share Posted March 17, 2014 I suspect it has more to do with your site's framework set up and/or the post back link to your search page. I see your URL is "index.php?search=XXX" The "?search" variable is part of the searched for keywords but it does not tell the index.php script which page to load. I suspect the URL should be something like "localhost/mmdb/index.php/search/?search=XXX" or simply "localhost/mmdb/search/?search=XXX" or maybe even "localhost/mmdb/search.php?search=XXX" Does the search page load at all (before you actually search for something?) If so, what is the URL of THAT page? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.