Ok, that means I need to know javascript. But what I do not understand is why there is all the difference. That is to show the same written a new page I made a few lines of code, and to display the same page should have a file of hundreds of lines of code.
And I tried the javascript, but there are still mistakes to be corrected, because when I press control the browser tells me: Error on page
HTML Code:
<HTML>
<HEAD>
<TITLE>CONTROL</TITLE>
<script language="Javascript" type="text/javascript">
<!--
var myRequest = null;
function CreateXmlHttpReq2(handler) {
var xmlhttp = null;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlhttp.onreadystatechange = handler;
return xmlhttp;
}
function myHandler2() {
if (myRequest.readyState == 4 && myRequest.status == 200) {
e = document.getElementById("ex4result");
e.innerHTML = myRequest.responseText;
}
}
function esempio4() {
var name = document.f1.username.value;
var r = Math.random();
myRequest = CreateXmlHttpReq(myHandler2);
myRequest.open("GET","check_user.php?username="+escape(name)+"&rand="+escape(r));
myRequest.send(null);
}
-->
</script>
</HEAD>
<BODY>
<form name="f1">
<input type="text" name="username" style="width: 230px"/><br><input type="button" onClick="esempio4()" value="Check availability" />
<DIV id="ex4result" STYLE="position:absolute; border-style:solid; border-width:1; border-color:black; width:200px; color:black; background-color:white"></div>
<br>
<input type="text" name="password" style="width: 230px"/>
</form>
</BODY>
</HTML>
PHP Code:
<?php
include("connectionDB.php");
if (!isset($_GET['username'])) { echo "Username not entered";
else
{
$username = $_GET['username'];
$query = "SELECT username FROM users WHERE username = '$username'";
$ris = mysql_query($query, $db);
$ris = mysql_num_rows($ris);
if($ris != '0') { echo "Username already in use" }
else { echo " Username available" }
?>
Bookmarks