Skip to content
Permalink
e2c3612312
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
60 lines (48 sloc) 1.91 KB
<?php
ini_set('error_reporting', ~E_NOTICE);
class Register extends CI_Controller {
function __Construct(){
parent::__Construct();
$this->load->database(); // load database
$this->load->model('User_Info_Model'); // load model
$this->load->helper('url');
//$this->output->enable_profiler(TRUE);
session_start();
}
public function index(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$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|valid_email');
if ($this->form_validation->run() == FALSE){
$this->load->view('templates/header');
$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
// add user to db, launch session, send to home
else {
//add user to db
$user = $this->User_Info_Model->addUser();
$data['user'] = $user;
//get user id, launch session, send to home
if($user !== []){
$this->session->set_userdata($user);
$data = $this->session->all_userdata();
//$this->load->view('login', $data);
redirect('/All_Tweets');
}
// if no, refresh register
else {
$this->load->view('templates/header');
$this->load->view('register', $data);
}
}
}
}