public function save() { if (isset($_POST['hdn_id'])) { $id = $_POST['hdn_id']; } else { $id = 0; } if ($id == 0) { $applicantModel = new applicantModel(); $result = $applicantModel->get_by_email($_POST['txt_email']); if ($result) { $view = new viewModel('result'); if (isset($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else { $lang = 'en'; } if ($lang == 'ar') { $link = "<a href='" . site_url . "/applicant/send_password'>هنا</a>"; $message = "هذا البريد مسجل عندنا بالفعل, اذا كنت نسيت كلمة المرور اضغط {$link}"; } else { $link = "<a href='" . site_url . "/applicant/send_password'>Here</a>"; $message = "This email already registered, If you forget password clik {$link}"; } $view->assign('message', $message); die; } } $username = $_POST['txt_username']; $password = $_POST['txt_password']; //$password=md5($password); $name = $_POST['txt_name']; $gender_id = $_POST['cmb_gender']; $birthdate = $_POST['txt_birthdate']; /* list($month, $day, $year) = split('[/.-]', $birthdate); //list($month, $day, $year) = explode("/", $birthdate); $birthdate=$year.'-'.$month.'-'.$day; */ $nationality_id = $_POST['cmb_nationality']; $country_id = $_POST['cmb_country']; $city_id = $_POST['cmb_city']; $region = $_POST['txt_region']; $address = $_POST['txt_address']; $phone = $_POST['txt_phone']; $mobile = $_POST['txt_mobile']; $email = $_POST['txt_email']; $marital_status_id = $_POST['cmb_marital_status']; $military_status_id = $_POST['cmb_military_status']; if (isset($_POST['chk_have_car'])) { $have_car = 1; } else { $have_car = 0; } if (isset($_POST['chk_have_driving_license'])) { $have_driving_license = 1; } else { $have_driving_license = 0; } $university = $_POST['txt_university']; $faculty = $_POST['txt_faculty']; $major = $_POST['txt_major']; $grade_id = $_POST['cmb_grade']; $career_objective = $_POST['txt_career_objective']; $position_id = $_POST['cmb_position']; $job_type_id = $_POST['cmb_job_type']; $business_field_id = $_POST['cmb_business_field']; $minimum_salary = $_POST['txt_minimum_salary']; $salary_currency_id = $_POST['cmb_salary_currency']; $applicantModel = new applicantModel(); $max_id = $applicantModel->get_max_id(); $id_insert = $max_id + 1; $cv_name = $username . $id_insert; $activation_code = $this->genRandomString(); $filename = $_FILES["flcv"]["name"]; $file_ext = substr($filename, strripos($filename, '.')); // strip name if ($file_ext == ".pdf" || $file_ext == ".doc" || $file_ext == ".docx" || $file_ext == ".dot") { //$newname = 'cvs/'.$filename; $newname = __SITE_PATH . '/views/cvs/' . $cv_name . $file_ext; if (move_uploaded_file($_FILES['flcv']['tmp_name'], $newname)) { //Activation link To send email //$link="<a href='".site_url."/applicant/activate/$activation_code'>Activate Your Acount At Osoolrec</a>"; $applicantModel = new applicantModel(); $applicantModel->save($id, $username, $password, $name, $gender_id, $birthdate, $nationality_id, $country_id, $city_id, $region, $address, $phone, $mobile, $email, $marital_status_id, $military_status_id, $have_car, $have_driving_license, $university, $faculty, $major, $grade_id, $career_objective, $position_id, $job_type_id, $business_field_id, $minimum_salary, $salary_currency_id, $cv_name . $file_ext, $activation_code); $view = new viewModel('result'); if (isset($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else { $lang = 'en'; } if ($lang == 'ar') { $message = 'تم التسجيل بنجاح, و تم ارسال رابط التفعيل على الايميل, يجب عليك تفعيل حسابك اولا '; } else { $message = 'You are registered successfully, Your activation link send to your Email, You must activate your account before login'; } $view->assign('message', $message); } else { $error = "Error: A problem occurred during file upload!"; echo $error; } } elseif (empty($filename)) { //Activation link To send email //$link="<a href='".site_url."/applicant/activate/$activation_code'>Activate Your Acount At Osoolrec</a>"; $applicantModel = new applicantModel(); $applicantModel->save($id, $username, $password, $name, $gender_id, $birthdate, $nationality_id, $country_id, $city_id, $region, $address, $phone, $mobile, $email, $marital_status_id, $military_status_id, $have_car, $have_driving_license, $university, $faculty, $major, $grade_id, $career_objective, $position_id, $job_type_id, $business_field_id, $minimum_salary, $salary_currency_id, $cv_name, $activation_code); $view = new viewModel('result'); if (isset($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else { $lang = 'en'; } if ($lang == 'ar') { $message = 'تم التسجيل بنجاح, و تم ارسال رابط التفعيل على الايميل, يجب عليك تفعيل حسابك اولا '; } else { $message = 'You are registered successfully, Your activation link send to your Email, You must activate your account before login'; } $view->assign('message', $message); } else { $error = "Only .pdf or .doc format can be submitted online."; echo $error; } }