Skip to content

Commit

Permalink
login and registration
Browse files Browse the repository at this point in the history
  • Loading branch information
cws13003 committed Nov 30, 2017
1 parent ab67490 commit 708f39a
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 55 deletions.
2 changes: 1 addition & 1 deletion www/application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = '';
$config['base_url'] = 'http://twitter-clone.lndo.site/';

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions www/application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
//$route['default_controller'] = 'pages/view';
//$route['(:any)'] = 'pages/view/$1';
14 changes: 0 additions & 14 deletions www/application/controllers/Form.php

This file was deleted.

21 changes: 21 additions & 0 deletions www/application/controllers/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

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

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

$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');

if ($this->form_validation->run() == FALSE)
$this->load->view('login');

// load the homepage if login successful
// https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods
else {
$this->load->view('formsuccess');
}
}
}
14 changes: 0 additions & 14 deletions www/application/controllers/Pages.php

This file was deleted.

27 changes: 27 additions & 0 deletions www/application/controllers/Register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

class Register extends CI_Controller {
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('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)
$this->load->view('register');

// load the homepage once properly submitted
// https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods
else {
$this->load->view('formsuccess');
}
}
}
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions www/application/views/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
$this->load->library('form_validation');
echo validation_errors();
echo form_open('login'); ?>

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

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

<br><br>
<div><input type="submit" value="Submit"/></div>

</form>
1 change: 0 additions & 1 deletion www/application/views/pages/login.php

This file was deleted.

23 changes: 0 additions & 23 deletions www/application/views/pages/register.php

This file was deleted.

File renamed without changes.
25 changes: 25 additions & 0 deletions www/application/views/register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
$this->load->library('form_validation');
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>Email Address</h5>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
<?php echo form_error('email'); ?>

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

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

<br><br>
<div><input type="submit" value="Submit"/></div>

</form>

0 comments on commit 708f39a

Please sign in to comment.