2013-03-12 54 views
0

我有这样的形式:笨提交到未知的形式

<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> 

请不要介意阿拉伯语writings.The控制器如下:

<?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的初学者,非常抱歉。

回答

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'); 

这就是它!

+0

真的,我这样做,但我真的很努力学习。问候。 – 2013-03-12 14:05:28

+0

@sys_debug标记答案,如果它帮助你! – sandip 2013-03-12 14:48:31

1

变化

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

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