1

Can anyone help me with this rather big problem. I have a booking form I designed with QuickDialog, that sends a request to a php file using the mail() function on my web server to send an email. It all works well, until it comes to errors. If I take the php file off of my website or disable the internet, when the send button is pushed, it says that the booking was sent, when it clearly wasnt. I cant remember where I got this code, maybe its wrong?

P.S, im using storyboard.

QButtonElement *button = [[QButtonElement alloc] initWithTitle:@"Submit Booking"];
button.onSelected = ^{

    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [root fetchValueIntoObject:dict];

    NSString *msg = @"Values:";
    for (NSString *aKey in dict){
        msg = [msg stringByAppendingFormat:@"\n- %@: %@", aKey, [dict valueForKey:aKey]];
    }


    NSLog(@"%s", __FUNCTION__);
    //Allocate NSURL object
    NSURL *nsURL = [[NSURL alloc] initWithString:kTextUrl];
    // Allocate NSMutableURLRequest
    NSMutableURLRequest *nsMutableURLRequest = [[NSMutableURLRequest alloc] initWithURL:nsURL];
    // Set HTTP method to POST
    [nsMutableURLRequest setHTTPMethod:@"POST"];

    // Set up the parameters to send.
    NSString *paramDataString = [NSString stringWithFormat:@"fname=%@&lname=%@&email=%@&mnumber=%@&treatment1=%@&datetime=%@&altdatetime=%@&therapist=%@&contactMethod=%@", fname.textValue, lname.textValue, email.textValue, mnumber.textValue, treatment1.selectedItems, datetime.textValue, altdatetime.textValue, therapist.textValue, contactMethod.selectedItem];
    NSLog(@"%s - paramDataString: %@", __FUNCTION__, paramDataString);
    // Encode the parameters to default for NSMutableURLRequest.
    NSData *paramData = [paramDataString dataUsingEncoding:NSUTF8StringEncoding];
    // Set the NSMutableURLRequest body data.
    [nsMutableURLRequest setHTTPBody: paramData];   
    // Create NSURLConnection and start the request.
    NSURLConnection *nsUrlConnection=[[NSURLConnection alloc]
                                      initWithRequest:nsMutableURLRequest 
                                      delegate:self];
    // Successful connection.
    if (nsUrlConnection) {
    [self performSegueWithIdentifier: @"segueSuccess" sender: self];

    }
    // Unsuccessful connection.
    else {

    [self performSegueWithIdentifier: @"segueFail" sender: self];
    }

};

The nsURL is defined in the header file.

Jayden Smith
  • 13
  • 1
  • 2

0 Answers0