Files
2021-10-09 21:59:14 -04:00

91 lines
3.2 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Signup extends CI_Controller {
public function index() {
$data["signup_error"] = "";
$firstname = NULL;
$country = 'NG';
$lastname = NULL;
$email = NULL;
$password = NULL;
$terms = NULL;
$news = NULL;
$terms = NULL;
$submit = NULL;
extract($_POST);
$data['firstname'] = $firstname;
$data['lastname'] = $lastname;
$data['email'] = strtolower($email);
$data['username'] = strtolower($email);
$data['password'] = $password;
$data['country'] = $country;
$data['news'] = 1; //$news;
$data['terms'] = $terms;
$ip = $this->input->ip_address();
$data['loc'] = $ip; //"38.101.241.200";
$this->load->model('combo_model');
$this->combo_model->defaultComboMessage = 'Select your Country';
$data['country_combo'] = $this->combo_model->getCountryCombo('country', $country);
$terms_checked = '';
// is anybody using this email already
$this->load->model('account_model');
$data['signup_error'] = '';
if ($_POST) { // post
if ($data['terms'] == 'on') {
$terms_checked = 'checked';
}
// $data['terms'] = 1; // note terms is turned to 1
//
// print_r($_POST);
if ($this->account_model->verifySignupInputs($data) == true) {
$email_in_use = false;
$data['terms'] = 1; // $terms is interger in backend;
if ($this->account_model->checkUsernameDuplicate($data) > 0) {
$email_in_use = true;
}
if ($email_in_use == false) {
$data['action'] = WRENCHBOARD_ACCOUNT_PENDING;
if ($_POST) {
if ($firstname !== '' && $lastname !== '') {
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($data, $out);
if ($res > 0) {
$data['account_email'] = strtolower($email);
redirect('outmessage', $data);
} else {
$data['signup_error'] = "Unable to create account";
}
}
}
} else {
$data['signup_error'] = "Please use another username";
}
} else {
$data['signup_error'] = "Enter all required fields";
}
} // if post
$data['signup_error_style'] = '';
if (strlen($data['signup_error']) > 0) {
$data['signup_error_style'] = "<div class=\"text-left\"><div class=\"alert alert-danger no-border\">" . $data["signup_error"] . "</div></div>";
}
$data['terms'] = $terms_checked;
$this->load->view('users/view_registration', $data);
$this->load->view('users/view_external_footer', $data);
}
}