如果只有用户名可用,我想在 php 中启用表单字段,否则字段应保持禁用状态。
我怎样才能做到这一点 ?
请看一下这个页面。任何人都可以帮忙吗?
代码:
<form action="" method="post" name="sampleform" id="form1">
<input name="uname" type="text" id="uname" class="uname" style="text-transform:lowercase;" />
<span class="req">*</span>
<input type="submit" name="chkuserid" value="Check User ID availability" id="chkuserid" class="btn" style="width:200px;" />
<?php
$con=mysql_connect("localhost","***","****")or die("Unable to connect");
mysql_select_db("****_salaam",$con)or die("Invalid");
if(isset($_POST['chkuserid']))
{
$nmu=$_POST['uname'];
$sql = mysql_query("SELECT * FROM member_reg where unm='$nmu'");
if(mysql_num_rows($sql)>0)
{
echo "Username already existing";
ob_flush();
}
else
{
echo "Username available";
}
}
?>