function recomplete()
 {
     $details = $this->db->where('unique_id', $this->input->post("merchant_param1"))->get("tbl_registration_student")->row();
     $this->load->helper("email");
     welcome_email($details->email, $details->user_id, $details->activation_link);
     $da["msg"] = '<div class="alert alert-success form-error" style="width:100%;">Your Registration is complete now. You can Login after Payment Done.</div>';
     $this->load->view("registration_student", $da);
 }
 function signup()
 {
     $error = array();
     $type = $_POST["type"];
     $class = "";
     $key = 0;
     if ($type == "student") {
         $first_name = $_POST["first_name"];
         if (trim($first_name) == "") {
             $error["error"][$key]["type"] = "first_name";
             $error["error"][$key]["msg"] = "First Name can not be blank.";
             $key++;
         }
         $last_name = $_POST["last_name"];
         if (trim($last_name) == "") {
             $error["error"][$key]["type"] = "last_name";
             $error["error"][$key]["msg"] = "Last Name can not be blank.";
             $key++;
         }
         $email = $_POST["email"];
         if (trim($email) == "") {
             $error["error"][$key]["type"] = "email";
             $error["error"][$key]["msg"] = "Email can not be blank.";
             $key++;
         }
         if (trim($email) != "") {
             if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                 $error["error"][$key]["type"] = "email";
                 $error["error"][$key]["msg"] = "Email is not validated.";
                 $key++;
             } elseif ($this->db->get_where('tbl_registration_student', array('email' => $email))->num_rows() > 0) {
                 $error["error"][$key]["type"] = "email";
                 $error["error"][$key]["msg"] = "Email Already Exists.";
                 $key++;
             }
         }
         $phone = $_POST["phone"];
         if (trim($phone) == "") {
             $error['error'][$key]["type"] = "phone";
             $error['error'][$key]["msg"] = "Phone No. Can not be blank";
             $key++;
         }
         if (trim($phone) != "") {
             if (!ctype_digit($phone) or strlen($phone) != 10) {
                 $error['error'][$key]["type"] = "phone";
                 $error['error'][$key]["msg"] = "Phone No. is Not Validated And Enter 10 digits only";
                 $key++;
             }
         }
         $password = $_POST["password"];
         if (trim($password) == "") {
             $error["error"][$key]["type"] = "password";
             $error["error"][$key]["msg"] = "Password can not be blank.";
             $key++;
         }
         $password_match = $_POST["password_match"];
         if (trim($password_match) == "") {
             $error["error"][$key]["type"] = "password_match";
             $error["error"][$key]["msg"] = "Confirm Password can not be blank.";
             $key++;
         }
         if (trim($password_match) != "") {
             if ($password != $password_match) {
                 $error["error"][$key]["type"] = "password_match";
                 $error["error"][$key]["msg"] = "Password and COnfirm Password are not same.";
                 $key++;
             }
         }
         $board = $_POST["course_board"];
         if (trim($board) == "") {
             $error["error"][$key]["type"] = "course_board";
             $error["error"][$key]["msg"] = "Board can not be blank.";
             $key++;
         }
         $class = $_POST["course_class"];
         if (trim($class) == "") {
             $error["error"][$key]["type"] = "course_class";
             $error["error"][$key]["msg"] = "Class can not be blank.";
             $key++;
         }
     }
     if ($key == 0) {
         $section_count = $this->db->get_where("tbl_registration_student", array("class" => $class, "board" => $board))->num_rows();
         $max_allowed = $this->db->get_where("tbl_class", array("class_id" => $class, "board_id" => $board))->row()->max_section_members;
         $error_int = intval($section_count / $max_allowed);
         $section = chr($error_int + 65);
         $data = array();
         $data["email"] = trim($email);
         $data["first_name"] = trim($first_name);
         $data["last_name"] = trim($last_name);
         $data["name"] = trim($first_name) . " " . trim($last_name);
         $data["password"] = md5(trim($password));
         $data["phone_no"] = $phone;
         $data["board"] = $board;
         $data["class"] = $class;
         $data["section"] = $section;
         $data["online"] = 0;
         $data["activation_status"] = 0;
         $this->db->insert("tbl_registration_student", $data);
         $insert_id = $this->db->insert_id();
         $activation_code = md5($insert_id . time());
         $this->db->where("user_id", $insert_id)->update("tbl_registration_student", array('activation_link' => $activation_code));
         $this->load->helper("email");
         welcome_email($email, $insert_id, $activation_code);
         $error["success"] = 1;
         $error["success_message"] = "Varify Your Email first. Your registration is completed.";
     } else {
         $error["success"] = 0;
     }
     return $error;
 }