php - How to go about an iPhone login page -
i wondering how start iphone login page. have tried using sql/php , connecting xcode, have had no success. best way it?
cribbing off a tutorial:
// loginexampleviewcontroller.h #import <uikit/uikit.h> @class loginexampleviewcontroller; @interface loginexampleappdelegate : nsobject <uiapplicationdelegate> { uiwindow *window; loginexampleviewcontroller *viewcontroller; } @property (nonatomic, retain) iboutlet uiwindow *window; @property (nonatomic, retain) iboutlet loginexampleviewcontroller *viewcontroller; @end // loginexampleviewcontroller.h #import <uikit/uikit.h> @interface loginexampleviewcontroller : uiviewcontroller { iboutlet uitextfield *unamefield; iboutlet uitextfield *passwordfield; iboutlet uibutton *loginbutton; nsmutabledata *receivedata; } @property (nonatomic, retain) uitextfield *unamefield; @property (nonatomic, retain) uitextfield *passwordfield; @property (nonatomic, retain) uibutton *loginbutton; @property (nonatomic, retain) nsmutabledata *receivedata; -(ibaction)dologin: (id)sender; @end // loginexampleviewcontroller.m #import "loginexampleviewcontroller.h" @implementation loginexampleviewcontroller @synthesize unamefield; @synthesize passwordfield; @synthesize loginbutton; @synthesize receivedata; // implement viewdidload additional setup after loading view, typically nib. - (void)viewdidload { [super viewdidload]; } //implement ibaction method -(ibaction) dologin: (id) sender { nsstring *uname= unamefield.text; nsstring *password= passwordfield.text; nsurl *theurl = [nsurl urlwithstring:[nsstring stringwithformat:@"http://localhost:8888/powerplay/insert2.php?name=%@&password=%@",uname, password]]; //here place url link nsurlrequest *req = [nsurlrequest requestwithurl:theurl]; nsurlconnection *connection = [nsurlconnection connectionwithrequest:req delegate:self]; if (connection) { nslog(@"connection successful"); } else { nslog(@"failed"); } } // implement connection delegate -(void) connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data{ } -(void) connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response{ [receivedata setlength:0]; // nsurl *theurl=[response url]; } -(void) connectiondidfinishloading:(nsurlconnection *)connection{ nslog(@"success",[receivedata length]); [connection release]; [receivedata release]; } // implement textfield delegate -(bool)textfieldshouldreturn:(uitextfield *)textfield{ [textfield resignfirstresponder]; return yes; } // implement touchevent -(void)touchesbegan :(nsset *)touches withevent:(uievent *)event { [super touchesbegan:touches withevent:event]; } - (void)didreceivememorywarning { // releases view if doesn't have superview. [super didreceivememorywarning]; // release cached data, images, etc aren't in use. } - (void)viewdidunload { [super viewdidunload]; // release retained subviews of main view. // e.g. self.myoutlet = nil; } - (void)dealloc { [unamefield release]; [passwordfield release]; [super dealloc]; } @end worked me, if have problems, leave comment.
Comments
Post a Comment