#define Kregist @ "Http://api.sucar.com.cn/mobile/index.php?app=mobile&controller=member&action=register"
#define Kland @ "Http://api.sucar.com.cn/mobile/index.php?app=mobile&controller=member&action=login"
@property (Nonatomic,strong) Uitextfield *username;
@property (Nonatomic,strong) Uitextfield *password;
@property (Nonatomic,strong) Uitextfield *email;
-(void) regist
{
Nsmutableurlrequest *request=[nsmutableurlrequest Requestwithurl:[nsurl urlwithstring:kregist];
Set Request type
[Request sethttpmethod:@ "POST"];
NSString * body=[nsstring stringwithformat:@ "username=%@&password=%@&email=%@", Self.userName.text, Self.password.text,self.email.text];
NSData *data=[body datausingencoding:nsutf8stringencoding];
Set the package body
[Request Sethttpbody:data];
[Nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue Mainqueue] completionHandler:^ ( Nsurlresponse *response, NSData *data, Nserror *connectionerror) {
Nsdictionary *dict=[nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutablecontainers Error:nil];
NSString *result=dict[@ "message"];
NSString *s=dict[@ "state"];
Nsinteger State=[s IntegerValue];
if (state==0) {
Uialertview *wrong=[[uialertview alloc] initwithtitle:@ "Warning" message:result delegate:self cancelbuttontitle:@ "OK" Otherbuttontitles:nil];
[Wrong show];
}else if (state==1)
{
Uialertview *right =[[uialertview alloc] Initwithtitle:nil message:@ "registered successfully" Delegate:self cancelbuttontitle:@ "OK" Otherbuttontitles:nil];
[Right show];
}
}];
}
Post request to send user information to the server