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:
- I had already redefined the base URL in the config file.
- 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.)
- 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/w开发者_开发百科elcome/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.
You need to edit $config['base_url']
in /system/application/config/config.php
.
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.
精彩评论