Features:
1. Realize the user registration function;
2. Implementing an existing user name cannot be registered;
3. User name, password non-null authentication;
4. Password confirmation; User Registration Interface register.html
<! DOCTYPE html>
User Registration General Handler
register.ashx
<%@ WebHandler language= "C #" class= "Register"%> using System;
Using System.Web;
Using System.Web.Script.Serialization;
Using Web1;
Using System.Data.SqlClient;
Using System.Data; public class Register:ihttphandler {public void ProcessRequest (HttpContext context) {context. Response.ContentType = "Application/json";//1. Modify the message type//1. Gets the user name and password string user=context. request["Name"].
Trim (); String Password=context. request["Password"].
Trim (); 4>>>>> prohibited words, word length limit can also add//2 ". Non-null check if (string. Isnullorwhitespace (user)) {context. Response.Write (New JavaScriptSerializer (). Serialize (New {status= "error", msg= "user name cannot be empty.
"}));
Return } if (string. Isnullorwhitespace (password)) {context. Response.Write (New JavaScriptSerializer (). Serialize (New {Status = "error", MSG = "Password cannot be empty.
" }));
Return }//3 ". Check for user name presence DaTatable dusers = sqlhelper.executequery ("Select username from t_users where username= @username", New System.Data .
Sqlclient.sqlparameter ("@UserName", user)); if (dusers.rows.count>1) {context. Response.Write (New JavaScriptSerializer ().
Serialize (New {status= "error", msg= "User already exists"});
Return }//4. Insert Database Sqlhelper.executenonquery ("INSERT into t_users (Username,password) VALUES (@username, @password)",
New SqlParameter ("@username", user), New SqlParameter ("@password", password)); Context. Response.Write (New JavaScriptSerializer ().
Serialize (New {status= "OK", msg= "registered successfully"});
} public bool IsReusable {get {return false; }
}
}
User Table
Run Results
errors (all letters are missing or wrongly written)
Summary:
Ajax-ajax,ajax,ajax,ajax,ajax, Ajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxa Jaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxaj Axajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajax .....