我是CI和PHP的新手。几天前,我能够很好地使用我的注册脚本,但现在我的脚本将不再发布任何数据。
我的" register.php":
class Register extends MY_Controller
{
private $CI;
function __construct()
{
parent::__construct();
$this->CI = & get_instance();
$this->CI->load->helper('form');
}
public function index($renderData="")
{
$this->title = "title";
$this->_render('pages/register',$renderData);
}
function verify()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|max_length[40]');
$this->form_validation->set_rules('password', 'Password', 'required|max_length[40]');
if ($this->form_validation->run() == FALSE)
{
}
else
{
$username = $this->input->post('username');
$password = $this->input->post('password');
redirect('home','refresh');
}
}
}
我的"页面/ register.php":
<body style="background-color: #F7F7F6">
<section>
<div class="container register">
<div class="row">
<div class="center span4 well">
<legend> Create an account</legend>
<form method="POST" accept-charset="UTF-8" action="<?php echo base_url('register/verify');?>">
<input type="text" id="username" class="span4" name="username" placeholder="Your Username"/>
<input type="password" id="password" class="span4" name="password"placeholder="Your Password" />
<p></p>
<button type="submit" name="submit" class="btn btn-primary btn-block">Sign Up</button>
</form>
</div>
</div>
</div>
</section>
<hr style="BORDER-RIGHT: medium none; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; HEIGHT: 1px">
</body>
那么有没有人知道为什么不发布注册信息呢?我记得重新启动XAMPP,似乎没有任何工作。
答案 0 :(得分:0)
有一个.htaccess问题。 你可以试试这个;
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
THIS ONE IS MAKING PROBLEMS -> # RewriteRule ^(.)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^(ACT=.)$ [NC]
RewriteRule ^(.)$ index.php?%1 [L]
RewriteCond $1 !^(images|css|style.css|favicon.ico|robots.txt|index.php) [NC]
RewriteRule ^(.) /index.php?/$1 [L]
你应该启用mod_rewrite
答案 1 :(得分:0)
试试这个:
class Register extends MY_Controller
{
private $CI;
function __construct()
{
parent::__construct();
$this->CI = & get_instance();
$this->CI->load->helper('form');
}
public function index($renderData="")
{
$this->title = "title";
$this->_render('pages/register',$renderData);
}
function verify()
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|max_length[40]');
$this->form_validation->set_rules('password', 'Password', 'required|max_length[40]');
if ($this->form_validation->run() == FALSE)
{
}
else
{
redirect('home','refresh');
}
}
答案 2 :(得分:-1)
首先在行下面改变
class Register extends MY_Controller
以下
class register extends MY_Controller
因为CI不接受类名中的大写字母。
修改: - 强>
根据您当前的代码示例,您更改了以下行
<form method="POST" accept-charset="UTF-8" action="<?php echo base_url('register/verify');?>">
以下
<form method="POST" accept-charset="UTF-8" action="<?php echo base_url();?>register/verify">
但我也想知道注册类的文件夹结构。