表单在页面中重复。我无法上传图片:(我不记得有任何循环。我非常需要帮助。这是我的
view_register.php
<body>
<h1>IMAGE HERE</h1>
<div id="body">
<br/>
<p class="body">
<!--trial-->
<?php
echo form_open('start');
$firstname = array(
'name' => 'firstname',
'value' => set_value('firstname')
);
$lastname = array(
'name' => 'lastname',
'value' => set_value('lastname')
);
$email = array(
'name' => 'email',
'value' => set_value('email')
);
$dateofbirth = array(
'name' => 'dateofbirth',
'value' => set_value('dateofbirth')
);
$gender = array(
'name' => 'gender',
'value' => set_value('gender'),
'style' => 'margin:10px'
);
$username = array(
'name' => 'username',
'value' => set_value('username')
);
$password = array(
'name' => 'password',
'value' => ''
);
$confpass = array(
'name' => 'confpass',
'value' => ''
);
?>
<!--trial ends here-->
<strong>User Information: </strong>
<div align="right"><font color="red">*</font>Denotes Required Field</div>
<div align="left">
First Name<font color="red">*</font>:
<?php echo form_input($firstname)?>
<br/>
Last Name<font color="red">*</font>:
<?php echo form_input($lastname)?>
<br/>
Email Address<font color="red">*</font>:
<?php echo form_input($email)?>
<br/>
Date Of Birth:
<?php echo form_input($dateofbirth)?>
<br/>
Gender:
<?php
echo form_radio($gender, 'Male');
echo "Male";
echo form_radio($gender, 'Female');
echo "Female";
?>
<br/>
<strong>Account Information:</strong><br/>
Username<font color="red">*</font>:
<?php echo form_input($username)?><br/>
Password<font color="red">*</font>:
<?php echo form_password($password)?><br/>
Password Confirmation<font color="red">*</font>:
<?php echo form_password($confpass)?><br/>
<?php
echo validation_errors();?>
<?php echo form_submit(array('name'=>'register'), 'Register');?>
<?php echo form_reset(array('name'=>'reset'), 'Reset')?>
</div>
</body>
这是我的 user.php。我不太确定代码。这些主要是我见过的表格教程..
class User extends CI_Controller {
private $view_data = array();
function _construct()
{
parent::_construct();
$this->view_data['base_url']=base_url();
}
function index()
{
$this->register();
}
function register()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('firstname', 'First Name', 'trim|required|max_length[100]|min_length[1]|xss_clean');
$this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|max_length[100]|min_length[1]|xss_clean');
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|max_length[100]|xss_clean|valid_email');
$this->form_validation->set_rules('dateofbirth', 'Date of Birth', 'trim|max_length[100]|min_length[1]|xss_clean');
$this->form_validation->set_rules('gender', 'Gender', 'trim|max_length[6]|min_length[6]|xss_clean');
$this->form_validation->set_rules('username', 'User Name', 'trim|required|alpha_numeric|callback_username_not_exists|max_length[100]|min_length[6]|xss_clean');
if ($this->form_validation->run() == FALSE)
{
//not run
$this->load->view('view_register', $this->view_data);
}
else
{
//good
$firstname=$this->input->post('firstname');
$lastname=$this->input->post('lastname');
$email=$this->input->post('email');
$dateofbirth=$this->input->post('dateofbirth');
$gender=$this->input->post('gender');
$username=$this->input->post('username');
$password=$this->input->post('password');
$this->User_model->register_user($firstname, $lastname, $email, $dateofbirth, $gender, $username, $password);
}
$this->load->view('view_register', $this->view_data);
}
然后在那之后我被卡住了。单击注册后,它说Page404 Not Found,甚至没有验证。