Posted by Danny on 08/16/06 14:15
Hi Mark,
Thnx 4 the hlp. But i already have the submit button which will
invoke the register.php page...thats y i used a button which invokes
javascript function(i know i'm complicating myself!)...which inturn
invokes PHP function!!!...pls hlp me to simplify my code.
here is my code:
<?php
include_once "siteincludes.php";
require_once "dbconnect.php";
function test($name)
{
$msg="";
$query="select * from tblusers where username='".$name."'";
$result=mysql_query($query);
if(mysql_num_rows($result)==0)
{
$msg="<font color='green'>"."User ID is not available!"."</font>";
}
else
{
$msg="<font color='red'>"."User ID is available!"."</font>";
}//end of else
echo $msg;
}
?>
<body>
<form name="registrationfrm" action="register.php" method="post">
User ID:<input type="text" name="cname">
<button onclick="checkuser()">Check Availability!</button>
<h6 id='display' name='display'></h6>
<script language=javascript>
function checkuser(){
name=document.registrationfrm.cname.value;
display.innerHTML="<?php $name='"+name+"'; test($name);?>";
}
</script>
</form>
</body>
Thanks,
Danny.
Navigation:
[Reply to this message]
|