0

私は Code Igniter Project に取り組んでいます。

ビューフォルダーにphpファイルがありますC:\xampp\htdocs\MSPN\APPLICATION\views

フォームは次のように記述します。

<form action="<?php echo base_url() .'homeSignUp/main'; ?>" method="post" >

ブラウザでは、ファイルは次の場所にあります。localhost/mspn/index.php/signup/main

config.php には次のものがあります。

$config['base_url'] = 'localhost/mspn/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

フォーム「アクション」は、メソッドを持つフォルダー内に向けることを意図してhomeSignUp.phpいます。controllermain

しかし、実行しようとすると、submitボタンがlocalhost/mspn/homeSignUp/main. そしてそれは言った:オブジェクトが見つかりません!

属性の URL を変更しようとしましたがaction、それでもエラーが発生し続けます。私は何を逃したのですか?ありがとう。

4

2 に答える 2

0

まず、index.phpを使用して URL から を削除します。.htaccess次に、URL は次のようになります。

localhost/mspn/signup/main

//Remove index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Prevents user access to the application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

そして、config.phpこの構成が必要です

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';

次に、フォームは次のようになります

echo form_open(base_url()."homeSignUp/main");

それが理にかなっていることを願っています

于 2013-06-22T11:11:41.347 に答える
0

まず、index_page構成を次のように変更します。

$config['index_page'] = 'index.php';

次に、site_url()次のように使用します。

<form action="<?php echo site_url('homeSignUp/main'); ?>" method="post" >

注:特定の を使用しているように見えるため、の代わりにroute使用することをお勧めします。signup/mainhomeSignUp/main

サイトの URL には両方base_urlindex_urlif there が含まれるためです。したがって、個別に言及する必要はありませんindex.php

于 2013-06-22T10:22:15.803 に答える