Hey,
I am using VB 3.8 and am trying to validate the password through an external app. Here is the PHP code I have
Code:
$username = isset($_GET[$usernameLabel]) ? ($_GET[$usernameLabel]) : "";
$password = isset($_GET[$passwordLabel]) ? ($_GET[$passwordLabel]) : "";
$userid = isset($_GET[$useridLabel]) ? $_GET[$useridLabel] : "";
$script = isset($_GET[$scriptLabel]) ? ($_GET[$scriptLabel]) : "";
$action = isset($_GET[$actionLabel]) ? $_GET[$actionLabel] : "";
switch($action){
case $actionLoginLabel:
$userid = -1;
$res = mysql_query("select `userid`,`username`,`password`,`salt` from `user` where 1",$sql_con);
while($row = mysql_fetch_array($res,MYSQL_ASSOC)){
if($row["password"] == md5(md5($password).$row["salt"]) && strtolower($row["username"]) == strtolower($username)){
$userid = $row["userid"];
break;
}
}
//echo(enc($userid));
echo($userid);
break;
and here is the java
Code:
private void loginButton_event(ActionEvent e) {
char[] p_raw = passwordTextBox.getPassword();
String p = "";
for(char c : p_raw){
p = p + Character.toString(c);
}
try {
userid = Integer.parseInt(getPage(DOMAIN+"?"+LABEL_ACTION+"="+LABEL_ACTION_LOGIN+"&"+LABEL_USERNAME+"="+usernameTextBox.getText()+"&"+LABEL_PASSWORD+"="+p));
} catch(NumberFormatException err){}
if(userid > -1){
username = usernameTextBox.getText();
password = p;
setVisible(false);
} else {
JOptionPane.showMessageDialog(this,"Incorrect login details!","Error!",JOptionPane.ERROR_MESSAGE);
}
}
It always shows as Incorrect login but I am using the right login/pass, can anyone help fix this please?