I have a register form and i want to check before submitting if the username is taken or not. I`m using the following php code:
Javascript and PHP
6
I have a register form and i want to check before submitting if the username is taken or not.
I`m using the following php code:
<?php
include ('connectandselectdatabase.php');
$check = "select id from $table where username = '".$_POST['username']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Allready taken!";
exit;
}
else {
echo "ok";
}
?>
I`m thing the best would be to use Javascript , something like onmouseout execute the php script , how i can done this , or if not what method to use?
Thanks for any help!
I`m using the following php code:
<?php
include ('connectandselectdatabase.php');
$check = "select id from $table where username = '".$_POST['username']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Allready taken!";
exit;
}
else {
echo "ok";
}
?>
I`m thing the best would be to use Javascript , something like onmouseout execute the php script , how i can done this , or if not what method to use?
Thanks for any help!
- n7 Studios
- [1] reply
- xiaophil
- [2] replies
Next Topics on Trending Feed
-
6