Generic remote server submit

From FacileWiki

Summary   : A generic solution to remote server data submission
Author    : Nick Boldra
Created   : 10.3.2006
Revisions :
Based on  : Facile Forms 1.4.1,  Joomla 1.0.8
Applies to: Facile Forms 1.4.1 ... 1.4.4, Joomla 1.0.0 ... 1.0.8, Mambo 4.5.1 ... 4.5.3

What it does

This code uses an HTTP POST method to automatically post all form element names and values and creates a data array to be sent to a remote server.If the server responds to request the form redirects to a success page, otherwise the appropriate error is shown.

Notes for use

1. Copy and paste the submit code from the "Begin submit" part of this test form inside the "Begin submit" part of your own form.

2. Now you need to edit the code so it points to your remote server,near the top of the code in the "Begin submit" you will find.

//Replace url with your own. $http = 'http://www.imdb.com/Find';
Change the url to your server address. Note: if this is a Mambo/Joomla url you may have to include the Itemid to maintain formatting.

Next you need to change the redirection url so the browser can redirect after the form has been submitted.

//Redirection to Success page (to page 2 of this form by default). //Your redirection url. $redir = "http://www.yoursite.com/index.php?option=com_facileforms&ff_name=generic1&ff_page=2";

The url defaults to page 2 of this form, change the url to the one you require.

3. Save then fill out your form and submit to test the code is working correctly.

4. If the message "Success" is displayed then the code has executed successfully. If you do this in Facile Forms admin then the success message will flash up and then the form will refresh,redirection will only happen if the form is submiited from the frontend.

If the form did not run correctly and an error was displayed it will be for one of three reasons.

  • The url that you have used is incorrect or mis typed.
  • The port number is wrong.
  • The socket number is wrong.

You will have to edit the code if you wish to use HTTPS and not HTTP.

Restrictions

For the submit code to work correctly you must make sure that you name all the relevant form fields exactly as the remote server requires.Below is the data array part of the submit code for this test form.

$d["select"] = "All"; $d["for"] = "The usual suspects"; You will notice that the form field names reflect the required data for the remote server as ["select"] and ["for"] and must not differ.

| Terms of Use | Privacy | Sitemap |
Editing tools
Personal tools