<?Php
//This is a JawaScript
?>

<script language="javascript" type="text/javascript">

function clearText(field)

{

if (field.defaultValue == field.value) field.value = '';

else if (field.value == '') field.value = field.defaultValue;

}

</script>

<script type="text/javascript">

function allready(str)

{

if (str=="")

{

document.getElementById("txtHint").innerHTML="";

return;

}

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{

document.getElementById("txtHint").innerHTML=xmlhttp.responseText;

}

}

xmlhttp.open("GET","getwriter.php?q="+str,true);

xmlhttp.send();

}
</script>

<?Php
//This is a PHP Code
?>

<?php
include("connection.php");
$a=$_REQUEST["q"];
$check = "SELECT * from writerregis where email= '".$a."'";
$qry = mysql_query($check);
$num_rows = mysql_num_rows($qry);

if($num_rows > 0){
// Here we are checking if username is already exist or not.


echo " This email id is already present.please select another email id.";

}

?>

<?php
//This is a form that is using the above javascript
?>


<tr>

<td><span class="style1">Email Id :</span></td>
<td><input type="email" name="email" class="input" placeholder="Enter Email Id" id="email" required onkeydown="allready(this.value)" required /><div id="txtHint" style="color:#FF0000"></div></td></tr>


When I am running this Code I am getting error Unidentified Index : q on line 3 that is the PHP Code. If anyone can help me in this, it would be a great help for me. Thanks for the help in advance.