WPS JSA连接mysql查询用户表字段信息验证登录账号

WPS JSA通过XMLHttpRequest + Webservice(PHP)实现连接Mysql查询用户表信息验证登录账号,验证通过后调用显示UserForm,代码如下供参考:

function CommandButton1_Click()

{

var xhr = new XMLHttpRequest();

var url = "http://localhost/test1/query.php";

xhr.open("GET", url, true);

xhr.send(null);

xhr.onreadystatechange = function() {

if (xhr.readyState === 4 && xhr.status === 200) {

// 处理响应数据

var responseData = JSON.parse(xhr.responseText); // 获取响应文本

// var value = responseData[0].un;

// var value1 = responseData[0].pw;

// Console.log(value);

// Console.log(value1);

//判断用户名和密码是否正确

if(TextEdit1.Value === responseData[0].un && TextEdit2.Value === responseData[0].pw){

alert('你好:'+ value + ' ,欢迎登录');

UserForm2.Show();

}else{

alert('用户名或密码不正确,请重新输入!');

}

}

}

}

效果示图:

Mysql表:

PHP文件代码:

广东省
浏览 1910
2
3
分享
3 +1
2 +1
全部评论