有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

PHP到Java论坛游戏集成

所以我正在创建一个游戏,并试图将论坛注册与登录整合到实际的游戏中。这是我的PHP代码

 <?php
$host = "localhost";
$user = "username";
$pass = "password";
$name = "database";
$_GET['name'] = str_replace("_"," ",$_GET['name']);
if($_GET['crypt'] != 168284692){
    echo '-1';
    exit;
}
if(!@mysql_connect($host, $user, $pass))  {
    die("error connecting to mysql server - " . mysql_error()); 
}
if(!@mysql_select_db($name))  {
    die("error selecting mysql database - " . mysql_error());
}
$query = mysql_query("SELECT * FROM forum_members WHERE members_display_name = '".$_GET['name']."'");
if($row = mysql_fetch_array($query)){

$pass2 = md5(md5($row["members_pass_salt"]).md5($_GET['pass']));
if($_GET['pass'] == $row["members_pass_hash"])
    echo ''.(2+$row["member_group_id"]);
else
    echo '1';
} else
echo '0';
?>

然而,问题不在于连接到数据库,这很好。问题是,当我从源代码中的页面调用时,它返回并运行catch异常

try {
            //the url for your website
            String urlString = "http://website.com/CheckUserOnLogin.php?crypt="+CRYPTION_ID+"&name="+user+"&pass="+pass;
            //open the connection to your website, this will throw and error if offline
            HttpURLConnection conn = (HttpURLConnection) new URL(urlString).openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            //read the result of the login
            String line = in.readLine().trim();
            System.out.println("Line: " + line);
            try {
                //parse the return code from the responce
                int returnCode = Integer.parseInt(line);
                switch(returnCode){
                case -1:
                    System.out.println("Wrong CRYPTION_ID");
                    return 10;
                case 1://invalid password
                    return 3;
                case 0://no member exists for this username
                    return 12;//say they must register on forum
                    //return 2;//allow login
                default://login ok
                    int member_group_id = returnCode-2;
                    return 2;
                }
            } catch(Exception e){
                System.out.println("here");
                //only called if failed to connect to the database
                System.out.println(line);
                return 8;//login server down
            }
        } catch(Exception e2){
            //should only happen if failed to connect to website
            e2.printStackTrace();
        }
        return 11;//website offline
    }

我正在使用IPB论坛,我不确定它为什么会返回这个</br>

谢谢-格兰特


共 (0) 个答案