hi, i want to check in my database table if "username" exists. this is my php script: <?php $query = "select username from members where username='$username'"; $ter = mysql_query($query); $num = mysql_num_rows($ter); if($num == 0) { $sql = "INSERT INTO members (id, username, password, email) VALUES ('', '$_POST[username]', md5('$_POST[password]'), '$_POST[email]')"; $result = @mysql_query($sql,$connection) or die(mysql_error()); } elseif($num > 0) { echo "user exists"; } ?> PHP: this script is working just fine but i want a way to display a message like "this username already exists" without refresh the page. can do it with javascript or AJAX? thanks in advance.
personally, i think this is overkill with something like AJAX. When they submit the whole form, just do your check as part of validation, and when if the form is invalidated, just post all your errors at once, including this one.