使用jquery ajax 我有一個輸入名稱的文本字段我如何在用戶輸入名稱時檢查該名稱ajax檢查名稱是否已存在在數據庫中,如果它顯示一條消息,該名稱已經存在,表單不能提交,直到輸入一個不存在的名稱?jquery ajax如何驗證db中是否存在記錄
這將是PHP
<?php
$name = $security->secure($_POST['name']) //security->secure() cleans the field
$query = $db->query("select name from table where name = '$name'");
if($db->num_rows($query) != 0) { "that record already exists"; }
//disable the form button until a name is entered that does not exist.
?>
我找到了一個很好的解釋thnx:http://vimeo.com/4173282 – 2010-12-07 23:55:49