Here i created a javascript+php code by which u can create a check available link that u will usually see in many websites.Withou t submitting the whole form just u can check wther a username exist in the database or not
=============== =============== =============== ====-=====
1:filenames: index.php
write a javascript fn like this in the head tag
<script language="javas cript">
function x()
{
var y=document.form 1.t.value;
open("newtest.p hp?value="+y,wi dth='10', height='10');
}
</script>
<body>
<form id="form1" name="form1" method="get" action="newtext .php?value=y;">
<p>
<input name="t" type="text" id="t" />
<a href="#" onclick="javasc ript:x();">chec kavailablity</a></p>
</form>
</body>
</html>
=============== =============== =============== =====
In 2 nd Page(newtest.ph p) you can access this value like :
$get_value=$_RE QUEST['value'];
//connect to the database
$query="select count(username) as us from <table> WHERE username='$get_ value'";
$res=mysql_quer y($query);
while($row=mysq l_fetch_array($ res))
{
if($rows['us']>=1)
{
echo "<div align='center'> <font color='red'><b> Sorry username exist</b></font></div>";
}
else
{
echo "<div align='center'> <font color='blue'><b >You can use this username</b></font></div>";
}
}
=============== =============== =============== ====-=====
1:filenames: index.php
write a javascript fn like this in the head tag
<script language="javas cript">
function x()
{
var y=document.form 1.t.value;
open("newtest.p hp?value="+y,wi dth='10', height='10');
}
</script>
<body>
<form id="form1" name="form1" method="get" action="newtext .php?value=y;">
<p>
<input name="t" type="text" id="t" />
<a href="#" onclick="javasc ript:x();">chec kavailablity</a></p>
</form>
</body>
</html>
=============== =============== =============== =====
In 2 nd Page(newtest.ph p) you can access this value like :
$get_value=$_RE QUEST['value'];
//connect to the database
$query="select count(username) as us from <table> WHERE username='$get_ value'";
$res=mysql_quer y($query);
while($row=mysq l_fetch_array($ res))
{
if($rows['us']>=1)
{
echo "<div align='center'> <font color='red'><b> Sorry username exist</b></font></div>";
}
else
{
echo "<div align='center'> <font color='blue'><b >You can use this username</b></font></div>";
}
}
Comment