codeigniter提交到未知的形式

时间:2013-03-12 13:59:58

标签: codeigniter codeigniter-2

我有这样的表格:

<html>
<head>
<title>التسجيل</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
</head>
<body dir="rtl">

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>

<h5>الإسم الكامل:</h5>
<input type="text" name="fullname" value="" size="50" />

<h5>الجوال:</h5>
<input type="text" name="mobile" value="" size="50" />

<h5>هاتف المنزل:</h5>
<input type="text" name="home" value="" size="50" />

<h5>اسم المستخدم:</h5>
<input type="text" name="username" value="" size="50" />

<h5>كلمة السر:</h5>
<input type="text" name="password" value="" size="50" />

<h5>اعادة كلمة السر:</h5>
<input type="text" name="cpassword" value="" size="50" />

<h5>الايميل:</h5>
<input type="text" name="email" value="" size="50" />
 <br><br>
<div><input type="submit" value="التسجيل" /></div>

</form>

</body>
</html>

请不要介意阿拉伯语的着作。控制器如下:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Membership extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');        
    }

    public function index()
    {
        //Loads the login page which has a registration option
        $this->load->view('login');
    }

    public function register()
    {
        $post = $this->input->post();
        if($post)
        {
            //handle posted data
            $fullname = $this->input->post('fullname');
            $email = $this->input->post('email');
            $mobile = $this->input->post('mobile');
            $home = $this->input->post('home');
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            $confirmPassword = $this->input->post('cpassword');
            $memberType = 'silver';

            if ($this->form_validation->run() == FALSE)
            {
                $this->load->view('register');
            }
            else
            {
                $this->load->view('welcome_message');
            }


        }else{
            $this->load->view('register');
        }
    }

}

现在当我点击表单上的提交按钮时,它显示404并且地址栏中的链接是: http://domain.com/index.php/form

为什么会这样?它应检查是否已发布,然后加载x。如果不加载y。

我是codeigniter的初学者,所以道歉。

2 个答案:

答案 0 :(得分:1)

您已从CI用户指南中复制代码:

   form_open('form'); // here is a form action which is form class index function

只需将其更改为:

  form_open('membership/register');

表示:

  form_open('location/to/sumbit/to');

就是这样!

答案 1 :(得分:1)

更改

<?php echo form_open('form'); ?> 

<?php echo form_open('membership/register'); ?> // class/function