//this is register.js
window.onload=initPage;
var request;
function initPage(){
var submit=document.getElementById("submit");//<input type="submit" id="submit>"
submit.onclick=getRegister;
}
function getRegister(){
request=createRequest();
if(request==null){
alert("unable to create request");
return;
}
var url="register.php";
request.open("GET",url,true);
request.onreadystatechange=checkAccount;
request.send(null);
}
function checkAccount(){
if(request.readyState==4){
if(request.status==200){
}
}
}
function createRequest() {
try {
request = new XMLHttpRequest();
} catch (tryMS) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
return request;
}
I have a register.php,a register.js,a register.html and with a four input:account,password,nickname,email. I have to check whether the account is already in the database,I know how to interact with mysql using php,the confusion is I don't know how to interact js and php,and where to compare the account,could you please show me the code examples?Thank you.(I'm trying to build a website such like stackoverfolw but not that awesome...I'm trying to learn by myself..)