Question: Given code function validateUname(uname) { var xhttp; if (uname != ) { xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 &&
Given code
function validateUname(uname) {
var xhttp;
if (uname != "") {
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var res = this.responseText;
}
};
xhttp.open("GET", "validuname.php?uname=" + uname, true);
xhttp.send();
}
}
Question:
Write a php page to handle the Ajax request.
The page should be named appropriately so it can be called by the server.
The page validates emails by checking if the emails have been used by other registered users.
Assume that all registered users are stored in a local MySQL database with the following parameters:
server: localhost;
database: mydb;
username: me;
password: myPa$$#;
table: tabUser;
username field: username.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
