codeigniter提交到未知表单
我有以下表格:codeigniter提交到未知表单,codeigniter,codeigniter-2,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('fo
<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');
}
}
}
您已从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');
就这样 变化
<?php echo form_open('form'); ?>
到
//类/函数
<?php echo form_open('membership/register'); ?> // class/function