네이티브 앱에서 그누보드 로그인 관련 문제

네이티브 앱에서 그누보드 로그인 관련 문제

QA

네이티브 앱에서 그누보드 로그인 관련 문제

본문

그누보드를 이용해서 네이티브 앱 하나를 만들고 있습니다.
가장 문제가 되는 부분이 로그인 인데요, 로그인과 관련해서는 아래처럼 파일을 하나 새롭게 생성 했습니다.

  1. <?php
  2. // Connect to the database(host, username, password)
  3. $con = mysql_connect('localhost','db접속ID','db접속 Pwd');
  4. if (!$con)
  5. {
  6. echo "Failed to make connection.";
  7. exit;
  8. }
  9. // Select the database. Enter the name of your database (not the same as the table name)
  10. $db = mysql_select_db('db이름');
  11. if (!$db)
  12. {
  13. echo "Failed to select db.";
  14. exit;
  15. }
  16. // $_POST['username'] and $_POST['password'] are the param names we sent in our click event in login.js
  17. $username = $_POST['mb_id'];
  18. $password = $_POST['mb_password'];
  19. // Select eveything from the users table where username field == the username we posted and password field == the password we posted
  20. $sql = "SELECT * FROM g4s_member WHERE mb_id = '".$username."' AND mb_password = '".$password."'";
  21. $query = mysql_query($sql);
  22. // If we find a match, create an array of data, json_encode it and echo it out
  23. if (mysql_num_rows($query) > 0)
  24. {
  25. $row = mysql_fetch_array($query);
  26. $response = array(
  27. 'logged' => true,
  28. 'name' => $row['mb_nick'],
  29. 'email' => $row['mb_email']
  30. );
  31. echo json_encode($response);
  32. }
  33. else
  34. {
  35. // Else the username and/or password was invalid! Create an array, json_encode it and echo it out
  36. $response = array(
  37. 'logged' => false,
  38. 'message' => 'Invalid Username and/or Password'
  39. );
  40. echo json_encode($response);
  41. }
  42. ?>



앱에서는 아래처럼 POST 방식으로 파라미터 값을 이용해서 로그인을 시도하고 있습니다.

http://url/post_auth.php



* param 값

mb_id : 사용자아이디,

mb_password : 사용자 비밀번호




그런데 자꾸만 앱에서는 Invalid Username and/or Password 메세지를 뿌리네요.


혹시 제가 뭐 잘못한 부분이 있따거나, 아니면 다른 좋은 방법이 없을까요?

이 질문에 댓글 쓰기 :

답변 1

패스워드는 암호화 되어서 저장되기 때문에, 비교할 때 암호화 시켜서 비교해야 할 것 같습니다. ^^
password('입력비번')  이렇게 감싸 보십시오..

그누보드는 mysql 자체의 password 함수를 사용합니다.
그누보드에서 로그인 아이디 비번 체크할 때 코드를 보면..
$row = sql_fetch(" select password('입력비번') as pass ");  이렇게 해서 가져와서
회원정보 디비의 비번 값과 비교합니다. ^^

답변을 작성하시기 전에 로그인 해주세요.
전체 59,555
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT