Skip to content

Commit

Permalink
registration
Browse files Browse the repository at this point in the history
  • Loading branch information
cws13003 committed Dec 4, 2017
1 parent dec5691 commit c35b8bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
14 changes: 11 additions & 3 deletions www/application/controllers/Register.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<?php

class Register extends CI_Controller {
function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Info_Model'); // load model
$this->output->enable_profiler(TRUE);
}

public function index(){
$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');

$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('firstname', 'First Name', 'required');
$this->form_validation->set_rules('lastname', 'Last Name', 'required');
$this->form_validation->set_rules('location', 'Location', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required',
array('required' => 'You must provide a %s.'));
$this->form_validation->set_rules('email', 'Email', 'required');

$this->form_validation->set_rules('email', 'Email', 'required|valid_email');

if ($this->form_validation->run() == FALSE)
Expand All @@ -21,6 +28,7 @@ public function index(){
// load the homepage once properly submitted
// https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods
else {
$this->User_Info_Model->addUser();
$this->load->view('formsuccess');
}
}
Expand Down
1 change: 0 additions & 1 deletion www/application/models/User_Tweets_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function addTweet(){
$slug = url_title($this->input->post('title'), 'dash', TRUE);

$data = array(
'id' => 500,
'tweet' => $this->input->post('tweet'),
'date_time' => 10,
'user_id' => 1
Expand Down
14 changes: 11 additions & 3 deletions www/application/views/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
echo validation_errors();
echo form_open('register'); ?>

<h5>Name</h5>
<input type="text" name="name" value="<?php echo set_value('name'); ?>" size="50" />
<?php echo form_error('name'); ?>
<h5>First Name</h5>
<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" size="50" />
<?php echo form_error('firstname'); ?>

<h5>Last Name</h5>
<input type="text" name="lastname" value="<?php echo set_value('lastname'); ?>" size="50" />
<?php echo form_error('lastname'); ?>

<h5>Email Address</h5>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
<?php echo form_error('email'); ?>

<h5>Location</h5>
<input type="text" name="location" value="<?php echo set_value('location'); ?>" size="50" />
<?php echo form_error('location'); ?>

<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<?php echo form_error('username'); ?>
Expand Down

0 comments on commit c35b8bb

Please sign in to comment.