일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- ajax
- 헬퍼
- 영카트
- 함수
- 코드이그나이터
- Database
- 안드로이드
- jw player
- FCM
- 웹 프로그래밍
- CI3
- MSsql
- jquery
- 그누보드
- mysql
- html
- function
- rairen
- 설정
- phpDocumentor
- php
- javascript
- CodeIgniter
- 후크
- 옵션표
- API
- 라이렌
- APK
- codeigniter3
- config
Archives
- Today
- Total
프로그램 개발서
[Jquery][CodeIgniter] 회원가입 관련 코드 모음. 본문
1. SignUp.js
var id_check = false;
$(document).on('blur', 'input[name="id"]', function () {
var id_check_text = $('.id_check_text');
if (this.value.length >= 4) {
var pattern1 = /[0-9]/;
var pattern2 = /[a-z]/;
var pattern_count = 0;
if (pattern1.test(this.value)) {
pattern_count++;
}
if (pattern2.test(this.value)) {
pattern_count++;
}
if (pattern_count === 1 || pattern_count === 2) {
var f = $(this).closest('form');
var id = this.value;
$.ajax({
url: [처리 주소],
type: 'post',
data: {
id: id,
pdx_csrf_token: $('input[name="' + csrf + '"]').val(),
},
dataType: 'json',
success: function (result) {
if (result.code === 'success') {
id_check_text.addClass('text-danger').text(result.message);
id_check = false;
}
else if (result.code === 'fail') {
id_check_text.addClass('text-success').text(result.message);
id_check = true;
}
else {
id_check_text.addClass('text-danger').text('ERROR : AJAX');
id_check = false;
}
f.find('input[name="' + result.data.csrf.name + '"]').val(result.data.csrf.hash);
},
error: function (error) {
console.log(error);
id_check = false;
},
});
}
else {
id_check_text.addClass('text-danger').text('영어 소문자, 숫자 외의 문자는 아이디로 이용하실 수 없습니다.');
id_check = false;
}
}
else if (this.value.length >= 1 && this.value.length < 4) {
id_check_text.addClass('text-danger').text('4자 이상으로 입해야합니다.');
id_check = false;
}
else {
id_check_text.addClass('text-danger').text('아이디는 필 수 입니다.');
id_check = false;
}
});
2. Process
public function sign_up()
{
$is_database = TRUE;
$id = $this->input->post('id', TRUE);
if (is_null($id))
{
$this->result = array(
'code' => 'fail',
'message' => '아이디를 입력하시기 바랍니다..',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
if (strlen($id) < 4)
{
$this->result = array(
'code' => 'fail',
'message' => '아이디는 4자 이상 입력해야합니다.',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
$password = $this->input->post('password', TRUE);
if (is_null($password))
{
$this->result = array(
'code' => 'fail',
'message' => '비밀번호를 입력하시 바랍니다..',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
if (strlen($password) < 4)
{
$this->result = array(
'code' => 'fail',
'message' => '비밀번호는 4자 이상 입력해야합니다.',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
$password_confirm = $this->input->post('password_confirm', TRUE);
if ($password !== $password_confirm)
{
$this->result = array(
'code' => 'fail',
'message' => '비밀번호가 일치하지 않습니다.',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
$captcha = $this->input->post('captcha', TRUE);
$row = $this->captcha_model->captcha_check($captcha);
if ($row->count == 0)
{
$this->result = array(
'code' => 'fail',
'message' => '자동등록방지 코드가 맞지 않습니다.',
'data' => array(
'csrf' => $this->data['csrf']
)
);
$is_database = FALSE;
}
$name = $this->input->post('name', TRUE);
$nick_name = $this->input->post('nick_name', TRUE);
$email = $this->input->post('email', TRUE);
$url = $this->input->post('url', TRUE);
if ($is_database)
{
$r = $this->member_model->sign_up($id, $password, $name, $nick_name, $email);
$this->result = array(
'code' => $r['code'],
'message' => $r['message'],
'url' => $url,
'data' => array(
'csrf' => $this->data['csrf']
)
);
}
$this->output->set_content_type('application/json')
->set_output(json_encode($this->result));
}
반응형
'Web' 카테고리의 다른 글
[코드이그나이터] Custom Helper Function 모음 - Default (0) | 2020.05.29 |
---|---|
[코드이그나이터] Custom Helper 모음 v0.1 (0) | 2020.05.20 |
mysqldump utf8 덤프 한글 문제 (0) | 2020.04.28 |
[코드이그나이터] 개발,시험,운영 환경 구분하는 ENVIRONMENT 설정 (0) | 2020.03.06 |
[페이스북]Access Token 만료 받지 않기 (0) | 2020.02.19 |