PHP + JQuery + Ajax user registration verification

Source: Internet
Author: User
This afternoon I studied jquery and made a simple user name check program to check whether the current user name already exists. Contains 4 files: jquery-1.4.jscheck.jscheck.htmlcheck.php

This afternoon I studied jquery and made a simple user name check program to check whether the current user name already exists.
Contains 4 files: jquery-1.4.js check. js check.html check. php
Where the jquery-1.4.js is JQuery code, you can download Oh. Check. js is a self-written file for verification.

The code is as follows:

 
 
  1. // Check. js
  2. $ (Document). ready (function (){
  3. $ ("# Username"). blur (function (){
  4. Var username = $ (this). val ();
  5. Var url = "check. php ";
  6. $. Post (url, {name: username}, function (str ){
  7. If (str = '1 '){
  8. $ ("# Info" ).html ("registered ");
  9. } Else {
  10. $ ("# Info" ).html ("registered ");
  11. }
  12. });
  13. });
  14. });
 
 
  1. // Check. php
  2. // Tianya PHP blog http://blog.phpha.com
  3. If (isset ($ _ POST ['name']) {
  4. $ Username = trim ($ _ POST ['name']);
  5. // Test only (database not queried). assume that the user name admin is registered.
  6. If ($ username = 'admin '){
  7. Exit ('1 ');
  8. }
  9. Exit ('0 ');
  10. }
  11. ?>
 
 
  1. // Check.html
  2. Script
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.