Thinkphp implements simple user registration

Source: Internet
Author: User
Thinkphp implements simple user registration

// This document is automatically generated for testing only
Class DengluAction extends Action
{
/**
+ ----------------------------------------------------------
* Default operation
+ ----------------------------------------------------------
*/
Public function index ()
{
$ This-> display ();
}

Public function doLogin ()
{

$ UserDao = M ('user ');
$ Data ['User _ name'] =$ _ POST ['User _ name'];
$ Data ['User _ password'] = $ _ POST ['User _ password'];
$ List = $ userDao-> where ($ data)-> find ();

If ($ list ['User _ limits '] = 2 ){
$ This-> assign ("num", 2 );
$ This-> display ();
}
If ($ list ['User _ limits '] = 1 ){
// Log in successfully based on the query results

/// Initialize the homepage //
// $ BlogDao = M ('zj ');
// $ MusDao = M ('Music ');
// Import ("ORG. Util. Page ");
// $ Count = $ blogDao-> count ();
/// Generate a paging object
// $ Page = new Page ($ count, 5 );
// $ List3 = $ blogDao-> order ('zj _ id')-> limit ($ page-> firstRow. ','. $ page-> listRows)-> select ();
// Foreach ($ list3 as $ k => $ v ){
//
// $ Data3 ['Music _ type'] = $ v ['zj _ name'];
//
// $ List1 = $ musDao-> where ($ data3)-> order ('Music _ id')-> limit (4)-> select ();
//
//
// $ List3 [$ k] ['music'] = $ list1;
//}
//
// $ Sh = $ page-> show ();
//// Initialize the message
// $ MessageDao = M ('message ');
// $ List2 = $ messageDao-> select ();
// $ This-> assign ("mess", $ list2 );
/// Initialization ends //
//

Session: set ("csdn", $ _ POST ['User _ name']);
$ This-> assign ('title', "Pan Xiaobai Music Night ");

$ This-> assign ('bloglist', $ list3 );

$ This-> assign ("show", $ sh );
$ This-> assign ("num", 1 );
$ This-> display ();
}

If ($ lista = NULL ){
$ This-> display ("denglu ");
}

}

Public function write ()
{
// Check whether the verification code is correct
If (md5 ($ _ POST ['yanzhen'])! = $ _ SESSION ['verify ']) {

$ This-> error ("incorrect verification code! ");
}
// Determine whether the two passwords are the same
If ($ _ POST ['User _ password']! = $ _ POST ['reuser _ password']) {

$ This-> error ("The two passwords are different! ");
}
$ UserDao = M ('user ');

If ($ UserDao-> create ()){

$ UserDao-> createtime = time ();

$ UserDao-> createuser = 'admin ';
// Determine whether the application is successfully added!
If ($ UserDao-> add ()){

// $ This-> success ("registration successful! ");
$ This-> display ("denglu ");
} Else {
$ This-> error ("Sorry! The server is busy !!! ");
}

} Else {

// If auto-fill fails, an error message is displayed.
$ This-> error ($ UserDao-> getError ());

}

}

Public function verify (){
Import ("ORG. Util. Image ");

Image: buildImageVerify ();

}

Public function checkUser ()
{

// Instantiate the model
$ UserDao = M ('user ');

// Query data in the database based on the user name
$ Data ['User _ name'] =$ _ POST ['User _ name'];
// If the query result is found, use the ajax method in ThinkPHP to return the status and data

$ Arr = array ('AAA' => 'BBB ', 3,4, 5, 1 );

$ List = $ userDao-> where ($ data)-> find ();

If ($ list ){
// Use Ajax to return the unavailable status
// Return data, return prompt information, status, format
$ This-> ajaxReturn ($ _ POST ['User _ name'], 'user name already exists ~ ', 0 );

} Else {

// Return data, return prompt information, status, format
$ This-> ajaxReturn (json_encode ($ arr), 'username'. $ _ POST ['User _ name']. 'can be used ~ ', 1 );
// Use Ajax to return the available status
}

}

}
?>

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.