views:

357

answers:

3

I have a CodeIgniter project with a very simple test application.

Controller opens a view (PHP page) which has a text box and a submit button. When I press the submit button, instead of redirecting to the appropriate function call in the controller, I get redirected to localhost/xampp.

here's the code on my view, which SHOULD be redirecting to the save_genre function in the controller named "welcome".

<?php echo form_open('welcome/save_genre');?>

<label for="radio_genre">Radio Genre</label>

<input type="text" name="radio_genre" id="radio_genre"></input>

<?php echo form_submit('submit','Save'); ?>

</form>

any ideas what could be wrong? I think it's not the code but is a setting or file wrong somewhere, but i don't know where to start looking.

EDIT:

  1. I had already redefined the base URL in the config file.
  2. I don't think I rewrote the .htaccess - but I'll certainly check. (This is a team project setup and I'll make sure no one else has done that.)
  3. As requested, below is the HTML output by the form. The URL link for the form seems very odd to me because it doesn't mention the project name like I would expect. So there are two places for me to look now. Thanks!

<body>
<h1>Welcome!</h1>
<form action="http://localhost/index.php/welcome/save_genre" method="post">
<label for="radio_genre">Radio Genre</label>

<input type="text" name="radio_genre" id="radio_genre"></input>

<input type="submit" name="submit" value="Save"  />
</form>
</body>

EDIT: OK - I recreated the project myself and then brought my PHP files in and it works fine. So the person who created the project did something odd.

+2  A: 

I can't comment yet so excuse this answer, but could you maybe post the HTML that this code generates?

Also, are you using URL rewriting (.htaccess)?

CriticalError
+5  A: 

You need to edit $config['base_url'] in /system/application/config/config.php.

Alix Axel
A: 

Somehow, while the index.php file was there in the file system, it wasn't being recognized as part of the project. Once I copied a new index.php file in there (identical file but it trigger the sense that "this changed.), I then went back into my project and refreshed and saved.

Everything then worked.

sql_mommy