Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:57:54+00:00 2026-05-28T05:57:54+00:00

I download CodeIgniter 2.1.0 and I followed the tutorial on CodeIgniter 2.1.0. The problem

  • 0

I download CodeIgniter 2.1.0 and I followed the tutorial on CodeIgniter 2.1.0.

The problem is when I try to submit a form in this URL:

http://localhost/CodeIgniter/index.php/news/create

the page is redirected to this URL:

http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create

I tired many ways to change the route.php but it doesn’t work. How can I fix this??

route.php

$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

This is the code for the form page:

public function create()
{
    $this->load->helper('form');
    $this->load->library('form_validation');

    $data['title'] = 'Create a news item';

    $this->form_validation->set_rules('title', 'Title', 'required');
    $this->form_validation->set_rules('text', 'text', 'required');

    if ($this->form_validation->run() === FALSE)
    {
        $this->load->view('templates/header', $data);   
        $this->load->view('news/create');
        $this->load->view('templates/footer');

    }
    else
    {
        $this->news_model->set_news();
        $this->load->view('news/success');
    }
}

I notice that when the form page when the page is loaded, below code segment will executed, however, the else segment never got changes to execute.

if ($this->form_validation->run() === FALSE)
    {
        $this->load->view('templates/header', $data);   
        $this->load->view('news/create');
        $this->load->view('templates/footer');

    }

This is the form page, nothing special, just call the create function shown above.
create.php

<h2>Create a news item</h2>

<?php echo validation_errors(); ?>

<?php echo form_open('news/create') ?>

<label for="title">Title</label> 
<input type="input" name="title" /><br />

<label for="text">Text</label>
<textarea name="text"></textarea><br />

<input type="submit" name="submit" value="Create news item" /> 

</form>

This is the HTML for the form page:

<html>
<head>
<title>Create a news item - CodeIgniter 2 Tutorial</title>
</head>
<body>
<h1>CodeIgniter 2 tutorial</h1><h2>Create a news item</h2>

<form action="localhost/CodeIgniter/index.php/news/create" method="post" accept-charset="utf-8">
<label for="title">Title</label> 
<input type="input" name="title" /><br />

<label for="text">Text</label>
<textarea name="text"></textarea><br />

<input type="submit" name="submit" value="Create news item" /> 

</form><strong>&copy;2012</strong>
</body>
</html>

And when I press the create new item button, the URL changed to

http://localhost/CodeIgniter/index.php/news/localhost/CodeIgniter/index.php/news/create

and page shows 404 Pages Not Found

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:57:54+00:00Added an answer on May 28, 2026 at 5:57 am

    I found the solution, it caused by the improper base url setting.

    Before my base url was: $config['base_url'] = 'localhost/CodeIgniter';

    Now I changed it to

    $config['base_url'] = 'http://localhost/CodeIgniter/';
    

    and it works fine now.

    Thanks for whoever tried to help:)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

download-dir: request-dir Print [downloading VStudio2008Express.iso ... ] url: http://go.microsoft.com/fwlink/?LinkId=104679 file-save: to-rebol-file rejoin [download-dir VStudio2008Express.iso]
Question about this helper http://codeigniter.com/user_guide/helpers/download_helper.html If, for example, program.exe weights 4 GB, will it
I download an image from an URL asynchronously using WebRequest this way: public void
URL Download http://code.google.com/p/mwiphonesdk/source/browse/#svn/trunk/iMADE/PrepTasks/08 I have code at the location at the link above and
I download an XML-file, I generate using PHP, that looks similar to this <?xml
Download JQGrid js file from http://www.trirand.com/blog/ . Is it free? What is this http://www.trirand.net/demoaspnetmvc.aspx
I have this jQuery call in a click event: var url = http://www.....; $('#platforms-lasers-video').load(url
I download and try to install the rpm package for fedora 10, i also
i download a kml file : <?xml version=1.0 encoding=UTF-8?> <kml xmlns=http://www.opengis.net/kml/2.2> <Document> <Style id=transGreenPoly>
I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.