penny94
10-31-2012, 03:15 AM
Hi I am trying to see if a username is already taken in my table.
The following code calls the Java function when the user clicks out of the textbox.. It works great but I have to manually enter a username where it says 'HERE!?'
I would like it to use the value of the textbox 'text'.
How would I go about doing this?
<script type="text/javascript">
function test(){
document.getElementById("php_code").innerHTML="<?php
include 'config.inc';
$dbunames = mysql_query("SELECT * FROM users WHERE username='HERE!?'");
if(mysql_num_rows($dbunames) > 0 ) {
echo "Already taken";
}
else
{
echo "available!";
}
?>";
}
</script>
<input name="text" onchange="test(); return false;" id="text" length="20">
<input name="text2" id="text2">
<span id="php_code"> </span>
Thanks
The following code calls the Java function when the user clicks out of the textbox.. It works great but I have to manually enter a username where it says 'HERE!?'
I would like it to use the value of the textbox 'text'.
How would I go about doing this?
<script type="text/javascript">
function test(){
document.getElementById("php_code").innerHTML="<?php
include 'config.inc';
$dbunames = mysql_query("SELECT * FROM users WHERE username='HERE!?'");
if(mysql_num_rows($dbunames) > 0 ) {
echo "Already taken";
}
else
{
echo "available!";
}
?>";
}
</script>
<input name="text" onchange="test(); return false;" id="text" length="20">
<input name="text2" id="text2">
<span id="php_code"> </span>
Thanks