0
我正在使用POST請求存儲一些用戶詳細信息,我的問題是用戶輸入這些詳細信息的任何詳細信息都應該到達我的電子郵件ID。我怎樣才能做到這一點 ?如何將用戶輸入的詳細信息發送至iOS中的電子郵件?
我的代碼是在這裏:
- (IBAction)NextButton:(id)sender {
NSLog(@"name:%@",nameTextField.text);
NSLog(@"emailid:%@",emailTextField.text);
NSLog(@"phonenumber:%@",phoneTextField.text);
NSLog(@"pickupaddress:%@",addressTextField.text);
if([nameTextField.text isEqualToString:@""] || [emailTextField.text isEqualToString:@""] || [phoneTextField.text isEqualToString:@""] || [addressTextField.text isEqualToString:@""])
{
UIAlertView* alertViewq = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please enter all the details." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertViewq show];
}
else
{
NSString *post = [NSString stringWithFormat:@"&name=%@&emailid=%@&phonenumber=%@&pickupaddress=%@",nameTextField.text,emailTextField.text,phoneTextField.text,addressTextField.text];
NSLog(@"post:%@",post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://example.com/userdetails.php"]]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection)
{
}
else
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Failed" message:@"Check your networking configuration." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
}