X-Cart

This guide is for integrating PHP scripts generated from Forms To Go with X-Cart to handle processing of additional forms. 

Forms To Go is a form processor and not a form generator. Therefore, knowledge of creating HTML forms in your favorite HTML editor is required.

In X-Cart, three (3) embedded pages are utilized for each form. 
Page 1 is the HTML form containing Forms To Go error placeholders. 
Page 2 is the Smarty include tag to the processing PHP script. 
Page 3 is the text to display after a successful submission.


Forms:

- Create your form using your favorite HTML editor. 
- Add Forms To Go error placeholders to the form to identify failed validation(s). For more information on placeholders, click here.
- For the ACTION attribute of the form, enter: pages.php?pageid=# (replace # with the page ID from step 2b)


In X-Cart:

1. Under Administration > General settings > General options, check "Parse Smarty tags in the content of embedded static pages" checkbox and click 'Save' button.

2. Under Administration > Static pages, in the Embedded Level section, create the three pages mentioned above.

a) Page 1 is the HTML form containing Forms To Go error placeholders. 
- Click 'Add new...' button.
- Enter a page filename. The location to this page will be used in Forms To Go in step 6.
- Enter a page name.
- For page content, paste the HTML form created from your HTML editor.
- Check "Show a link to the page in Help menu?" checkbox.
- Click 'Save' button.
- To find out the page ID of this page to use in step 3, click on the Preview link. The pageid will be shown in the URL address bar of your browser.



b) Page 2 is the Smarty include tag to the processing PHP script. 
- Click 'Add new...' button.
- Enter a page filename.
- Enter a page name.
- For page content, enter: {include_php file="custom-form.php"} (script name is from step 7
- Don't check "Show a link to the page in Help menu?" checkbox.
- Click 'Save' button.
- To find out the page ID of this page to use for the ACTION attribute of the form, click on the Preview link. The pageid will be shown in the URL address bar of your browser.



c) Page 3 is the text to display after a successful submission.
- Click 'Add new...' button.
- Enter a page filename.
- Enter a page name.
- For page content, enter the text.
- Don't check "Show a link to the page in Help menu?" checkbox.
- Click 'Save' button. 
- To find out the page ID of this page to use in Forms To Go in step 5, click on the Preview link. The pageid will be shown in the URL address bar of your browser.




In Forms To Go:

3. Under File > Load HTML Form from URL, enter the URL to the form to load into Forms To Go. 


Apply validations to the form fields.

4. Under Settings > Email to Form's Owner, configure the email information.

5. Configure the success landing page.
- Under Settings > Landing Pages - Success - Redirect, enter: pages.php?pageid=# (replace # with the page ID from step 2c)



6. Configure the error landing page.
- In X-Cart, under Administration > Static pages, edit the HTML form.

- Highlight (highlighted in yellow) and copy the path to the HTML form.


- Under Settings > Landing Pages - Error - HTML form, paste the path to the HTML form.



7. Go to Script > Create PHP Script - save the script to the root folder of x-cart. (script name to use in step 2b

#######

To handle file uploading in form, make the following change (highlighted in bold) in top.inc.php found in the root foder of x-cart (line 126):

if (!in_array($__key, array("GLOBALS","HTTP_GET_VARS","HTTP_POST_VARS","HTTP_SERVER_VARS","HTTP_ENV_VARS", "HTTP_COOKIE_VARS","HTTP_POST_FILES","__key","__val", "_GET","_POST","_SERVER","_COOKIE","HTTP_RAW_POST_DATA", "_FILES"))) {
unset($__key);
}