네이티브 앱에서 그누보드 로그인 관련 문제
본문
그누보드를 이용해서 네이티브 앱 하나를 만들고 있습니다.
가장 문제가 되는 부분이 로그인 인데요, 로그인과 관련해서는 아래처럼 파일을 하나 새롭게 생성 했습니다.
앱에서는 아래처럼 POST 방식으로 파라미터 값을 이용해서 로그인을 시도하고 있습니다.
http://url/post_auth.php
* param 값
mb_id : 사용자아이디,
mb_password : 사용자 비밀번호
그런데 자꾸만 앱에서는 Invalid Username and/or Password 메세지를 뿌리네요.
혹시 제가 뭐 잘못한 부분이 있따거나, 아니면 다른 좋은 방법이 없을까요?
가장 문제가 되는 부분이 로그인 인데요, 로그인과 관련해서는 아래처럼 파일을 하나 새롭게 생성 했습니다.
- <?php
- // Connect to the database(host, username, password)
- $con = mysql_connect('localhost','db접속ID','db접속 Pwd');
- if (!$con)
- {
- echo "Failed to make connection.";
- exit;
- }
- // Select the database. Enter the name of your database (not the same as the table name)
- $db = mysql_select_db('db이름');
- if (!$db)
- {
- echo "Failed to select db.";
- exit;
- }
- // $_POST['username'] and $_POST['password'] are the param names we sent in our click event in login.js
- $username = $_POST['mb_id'];
- $password = $_POST['mb_password'];
- // Select eveything from the users table where username field == the username we posted and password field == the password we posted
- $sql = "SELECT * FROM g4s_member WHERE mb_id = '".$username."' AND mb_password = '".$password."'";
- $query = mysql_query($sql);
- // If we find a match, create an array of data, json_encode it and echo it out
- if (mysql_num_rows($query) > 0)
- {
- $row = mysql_fetch_array($query);
- $response = array(
- 'logged' => true,
- 'name' => $row['mb_nick'],
- 'email' => $row['mb_email']
- );
- echo json_encode($response);
- }
- else
- {
- // Else the username and/or password was invalid! Create an array, json_encode it and echo it out
- $response = array(
- 'logged' => false,
- 'message' => 'Invalid Username and/or Password'
- );
- echo json_encode($response);
- }
- ?>
앱에서는 아래처럼 POST 방식으로 파라미터 값을 이용해서 로그인을 시도하고 있습니다.
http://url/post_auth.php
* param 값
mb_id : 사용자아이디,
mb_password : 사용자 비밀번호
그런데 자꾸만 앱에서는 Invalid Username and/or Password 메세지를 뿌리네요.
혹시 제가 뭐 잘못한 부분이 있따거나, 아니면 다른 좋은 방법이 없을까요?
답변을 작성하시기 전에 로그인 해주세요.