Я новичок в коде воспламенителя, но я смотрел много видео на YouTube, и я начинаю понимать основы этого, однако после того, как я выполню тестовый прогон в моей регистрационной форме, он переходит на белую страницус Запрошенный URL / kowmanager / user / register не найден на этом сервере.Я не уверен почему.Есть идеи?
Контроллер:
function User()
{
parent :: __construct();
$this->view_data['base_url'] = base_url();
$this->load->model('User_model');
}
function index()
{
$this->register();
}
function register()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|min_length[6]|xss_clean|strtolower|callback_usernameNotExists');
$this->form_validation->set_rules('password', 'Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
$this->form_validation->set_rules('passwordConfirm', 'Confirm Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[6]|xss_clean|valid_email|callback_emailNotExists');
$this->form_validation->set_rules('firstName', 'First Name', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
$this->form_validation->set_rules('lastName', 'Last Name', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('view_register', $this->view_data);
}
else
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$firstName = $this->input->post('firstName');
$lastName = $this->input->post('lastName');
$registrationKey = substr(md5(mt_rand()), 0, 5);
$this->User_model->registerUser($username, $password, $email, $firstName, $lastName, $registrationKey);
}
}
function usernameNotExists($username)
{
$this->form_validation->set_message('usernameNotExists', ' That %s already exists inside the database!');
if($this->User_model->checkExistsUsername($username))
{
return false;
}
else
{
return true;
}
}
function emailNotExists($username)
{
$this->form_validation->set_message('emailNotExists', ' That %s already exists inside the database!');
if($this->User_model->checkExistsEmail($email))
{
return false;
}
else
{
return true;
}
}
}
?>
Просмотр страницы:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>KOW Manager Registration Form</title>
</head>
<body>
<?php
echo form_open($base_url . 'user/register');
$username = array ('name' => 'username', 'id' => 'username', 'value' => set_value('username'));
$password = array ('name' => 'password', 'id' => 'password', 'value' => '');
$passwordConfirm = array ('name' => 'passwordConfirm', 'id' => 'passwordConfirm', 'value' => '');
$email = array ('name' => 'email', 'id' => 'email', 'value' => set_value('email'));
$firstName = array ('name' => 'firstName', 'id' => 'firstName', 'value' => set_value('firstName'));
$lastName = array ('name' => 'lastName', 'id' => 'lastName', 'value' => set_value('lastName'));
?>
<?php echo form_fieldset('User Information') ?>
<dl>
<dt><label for="username">Username:</label></dt>
<dd><?php echo form_input($username); ?></dd>
</dl>
<dl>
<dt><label for="password">Password:</label></dt>
<dd><?php echo form_password($password); ?></dd>
</dl>
<dl>
<dt><label for="passwordConfirm">Confirm Password:</label></dt>
<dd><?php echo form_password($passwordConfirm); ?></dd>
</dl>
<dl>
<dt><label for="email">Email Address:</label></dt>
<dd><?php echo form_input($email); ?></dd>
</dl>
<dl>
<dt><label for="firstName">First Name:</label></dt>
<dd><?php echo form_input($firstName); ?></dd>
</dl>
<dl>
<dt><label for="lastName">Last Name:</label></dt>
<dd><?php echo form_input($lastName); ?></dd>
</dl>
<?php echo form_fieldset_close() ?>
<?php echo validation_errors() ?>
<dl class="submit">
<?php echo form_submit(array('name' => 'register'), 'Register'); ?>
</dl>
<?php echo form_close(); ?>
</body>
</html>
Редактировать:
Вот мой новый код, который все еще делает то же самое.
<?php
class User extends CI_Controller {
function User()
{
parent :: __construct();
$this->view_data['base_url'] = base_url();
$this->load->model('User_model');
}
function index()
{
$this->register();
}
function register()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|min_length[6]|xss_clean|strtolower|callback_usernameNotExists');
$this->form_validation->set_rules('password', 'Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
$this->form_validation->set_rules('passwordConfirm', 'Confirm Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[6]|xss_clean|valid_email|callback_emailNotExists');
$this->form_validation->set_rules('firstName', 'First Name', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
$this->form_validation->set_rules('lastName', 'Last Name', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('view_register', $this->view_data);
}
else
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$firstName = $this->input->post('firstName');
$lastName = $this->input->post('lastName');
$registrationKey = substr(md5(mt_rand()), 0, 5);
$this->User_model->registerUser($username, $password, $email, $firstName, $lastName, $registrationKey);
$this->load->library('email');
$this->email->from('kowmanagement@kansasoutlawwrestling.com', 'KOW Management');
$this->email->to($email);
$this->email->subject('KOW Manager Account Registration');
$this->email->message('Hello '.$firstName.' '.$lastName.' Welcome to our website!<br /><br />You, or someone using your email address, has completed registration at '.myDomainName().'. You can complete registration by clicking the following link:<br /><br />' . anchor('http://www.'.myDomainName().'/manager/verify.php?userID='.$userID.'&verifyHash='.$verifyHash.'", http://www.'.myDomainName().'/manager/verify.php?userID='.$userID.'&verifyHash='.$verifyHash.''));
$this->email->send();
}
}
function registerConfirm()
{
$registrationKey = $this->uri->segment(3);
if ($registrationKey == '')
{
echo 'No registration key found in URL';
exist();
}
$registrationConfirmed = $this->User_model->confirmRegistration($registrationKey);
if ($registrationConfirmed)
{
echo 'You have successfully registered!';
}
else
{
echo 'You have failed to register!';
}
}
function usernameNotExists($username)
{
$this->form_validation->set_message('usernameNotExists', ' That %s already exists inside the database!');
if($this->User_model->checkExistsUsername($username))
{
return false;
}
else
{
return true;
}
}
function emailNotExists($username)
{
$this->form_validation->set_message('emailNotExists', ' That %s already exists inside the database!');
if($this->User_model->checkExistsEmail($email))
{
return false;
}
else
{
return true;
}
}
function myDomainName()
{
$my_domain = $_SERVER['HTTP_HOST'];
$my_domain = str_replace('www.', '', $my_domain);
return $my_domain;
}
}
?>
Есть еще идеи?