0

i am creating a register and login form in XCode.. have four textfields 1. nameText 2. MessageText 3. emailidText 4. passwordText

it was running good when i have first 2 fields and when i added emailid and password TExts, mysql database table is updated like all textfields in one cell.for Example

  1. nameText - selva
  2. MessageText - hello
  3. emailidText - abc@abc.com
  4. passwordText - xxxxxx

it update like selva?message=hello?emailid=abc@abc.com?password=xxxxxx on the name cell and rest of the 3 cells in table are empty...

i checked my PHP by creating HTML file and linked to it, it is working very fine. NOTE: i am working on online HOSt and online MYSQL database....

this is what i am declared in my viewcontroller.m

-(void)postMessage:(NSString*) message withName:(NSString *) name withName:     (NSString*)emailid withName:(NSString *)password 



{
if (name !=nil && message != nil && emailid !=nil && password !=nil)
{
    NSMutableString *postString = [NSMutableString stringWithString:kpostURL];


    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kName, name]];


    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kMessage, message]];

    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kemailid, emailid]];

    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kpassword,  password]];

    [postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]];
    [request setHTTPMethod:@"POST"];

    postConnection =[[ NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];



}
}

-(IBAction)post:(id)sender
{
 [self postMessage:messageText.text withName:nameText.text withName:emailidText.text  withName:passwordtext.text];

passwordtext.text= nil;
messageText.text= nil;
nameText.text = nil;
emailidText.text=nil;

}

created macros in viewcontroller.h and declared the four fields too..

i dont know why i am getting my o/p of all the four fields in one cell??

can anyone help me to clear my error please..

Selva
  • 50
  • 8
  • Not sure how this is PHP related. – str Jul 08 '13 at 21:02
  • i put my view ocntroller .h file too ..please wait – Selva Jul 08 '13 at 21:03
  • ' #import ' '#define kpostURL @"http://www.abc.net/xxx.php"' '#define kName @"name"' '#define kMessage @"message"' '#define kemailid @"emailid"' '#define kpassword @"password"' '@interface FirstViewController : UIViewController' '{' 'IBOutlet UITextField *nameText;' 'IBOutlet UITextField *emailidText;' 'IBOutlet UITextField *passwordtext;' 'IBOutlet UITextField *messageText;' 'NSURLConnection *postConnection;' '}' '-(IBAction)post:(id)sender;' '-(IBAction)screenTouch:(id)sender;' ' @end ' – Selva Jul 08 '13 at 21:10
  • You build POST request completely wrong. You inject your data into the URL string while you should accumulate it and put it as POST body. This question was asked 100000 times. Check out the working sample code: http://stackoverflow.com/a/6149088/351305 – Ben Affleck Jul 08 '13 at 21:15
  • can you help me please??????? – Selva Jul 08 '13 at 21:18
  • hi ya ,, thanks for the example you linked ....i am very new and freaking out ..can you help me with my example please.. that will save my time and it will be very helpfull – Selva Jul 08 '13 at 22:27

0 Answers0