Home  >  Article  >  Backend Development  >  ajax+php verification user name duplicate code example_PHP tutorial

ajax+php verification user name duplicate code example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:05:081259browse

This tutorial uses ajax php. After the user enters the user name, it will send a request to the php program, and then query the data to determine whether the user name the user wants to register has already been registered or is duplicated. In a timely manner The return prompt message is to prevent the user from filling out a large form and suddenly providing a username that cannot be registered and has been registered, which will cause a bad experience. This tutorial is specifically designed to solve this problem. It can quickly tell you whether the user name you want to register can be registered.

Ajax+php tutorial to verify user name duplicate code example

/*
This tutorial uses ajax php. After the user enters the user name, it will send a request to the php program, and then query the data to determine whether the user name to be registered has already been registered or is duplicated, and prompts are returned in a timely manner. Information to prevent users from filling in a large form and suddenly providing a username that cannot be registered and has been registered, which will cause a bad experience. This tutorial is specifically designed to solve this problem. It can quickly tell you whether the user name you want to register can be registered.
*/
?>




ajax+php verification user name duplicate code example






Enter user name
        
 



Save the following code into 忝13.php

checkusername();
function checkusername()
{
 $title = trim($_get['title']);
 if( empty( $title ) )
 {
  return false;
 }
 else
 {
  mysql教程_connect('localhost','root','root');
  mysql_select_db('test');
  mysql_query("set names 'gb2312'");
  $sql = "select * from cn_user where username ='$title'";
  
  $row = mysql_query($sql);
  
  if( mysql_num_rows( $row ) )
  {
   echo 1;
  }
  else
  {
   return null;
  }
 }
}

/*
create table `test`.`cn_user` (
`id` int not null auto_increment ,
`username` varchar( 20 ) not null ,
`times` date null ,
primary key ( `id` )
) engine = myisam

插入数据

insert into `test`.`cn_user` (
`id` ,
`username` ,
`times`
)
values (
null , 'jimmy', null
), (
null , 'www.bKjia.c0m', null
);

*/
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630819.htmlTechArticle本教程是一款利用了ajax php在用户输入完用户名后,就会发送请求给php程序,然后查询数据,判断用户要注册的用户名是不是己经注册或存在...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn