Welcome Guest, Not a member yet? Register   Sign In
Problem with beginner tutorial
#1

[eluser]Unknown[/eluser]
Hey! So I've recently started reading the CI documentation, and I've come across something that's totally stumped me.

Code:
<h2>Create a news item</h2>

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('news/create') ?&gt;

<label for="title">Title</label>
&lt;input type="input" name="title" /&gt;&lt;br />

<label for="text">Text</label>
&lt;textarea name="text"&gt;&lt;/textarea><br />

&lt;input type="submit" name="submit" value="Create news item" /&gt;

&lt;/form&gt;

When I press submit it ends up with the URL:

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

And an error 404 cannot find webpage

Only solution I've found is:

Code:
<h2>Create a news item</h2>

&lt;?php echo validation_errors(); ?&gt;

&lt;?php //echo form_open('news/create') ?&gt; !Commented out
&lt;form method="post" action="create"&gt; Replace with manual form

<label for="title">Title</label>
&lt;input type="input" name="title" /&gt;&lt;br />

<label for="text">Text</label>
&lt;textarea name="text"&gt;&lt;/textarea><br />

&lt;input type="submit" name="submit" value="Create news item" /&gt;

&lt;/form&gt;

Any insight on why it isn't work the way it should be? It's probably something obvious but I've googled around and have been unsuccessful any help would be very much appreciated!
#2

[eluser]Unknown[/eluser]
Actually it happens for any link or form its just appended onto the current URL. I've modifed the .htaccess to remove the index.php like the showed in the documentation
#3

[eluser]InsiteFX[/eluser]
.htaccess

You need to add this to it if you remove index.php:
Code:
RewriteEngine On
RewriteBase /http://localhost/ciblog/public_html

#and

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://localhost/ciblog/public_html/index.php/$1 [L,QSA]

Should give you and idea of how it works, paths will be your own paths.

This will invoke the index.php through the path.
#4

[eluser]Aken[/eluser]
I bet your base_url config setting is written incorrectly. It needs to be a full URL, IE http://localhost/




Theme © iAndrew 2016 - Forum software by © MyBB