The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Processing data on other servers

Due to reasons outlined here, I'm trying to transfer data between servers without using the URL. Below are the scripts I'm using to do this. The test.php is the one run in the browser, it adds a form which when submitted sends the results to an external script on another server. The index.php file processes the data. The data.php file provides the data for use by the original server and the style.php file provides CSS data which creates coloured blocks based on hex colour codes submitted by the form.

My intention was to grab the processed results via the readfile() function. Unfortunately the session variables I placed the resulting data into are not read by the readfile() function, presumably because the server the test.php file is on is trying to access the data and not the users browser. I was hoping javascript might have the answer, but from another topic I posted this seems to be not possible

Oops! I forgot to add the code for the index.php file to my post. It is added now.

Originally Posted by Dan Grossman

You're trying to print in the CSS file the colors they submitted with the form? If so, what's the purpose of the colors in data.php?

The data.php file generates a list of the colours. This list is used in line four of the test.php file. It grabs the data.php page data, sticks it into a variable called $data and then explodes that into an array. The data from the array is then used to repopulate the form.

While writing this post I thought of an alternative approach. Since I'm not modifying the data, I might be able to store it all on the server which test.php is hosted on. Originally I hadn't used that approach as I wanted a way to confirm that the data had indeed been processed, but I can do a check for that by having the other server redirect back to a URL randomly generated and sent by the test.php file. This would involve less data transfer too so the pages should load a little quicker too.

I want to release a piece of software for download, which allows users to choose a bunch of different options. When they click submit, those options are sent through to my own server for processing. My server will process them and all the user to download CSS created during this processing (that's what the style.php file is for).

I could store everything on my own server, but I want to make the bulk of the software free to download so that users can modify it for their own purposes. However for commercial purposes I want to keep the core code which does the processing on my own server.

The catch here, is that the number of options in the form (test.php) will be quite large and so I can't just send the data back via the URL.

I think I answered my own question with the following though:

While writing this post I thought of an alternative approach. Since I'm not modifying the data, I might be able to store it all on the server which test.php is hosted on. Originally I hadn't used that approach as I wanted a way to confirm that the data had indeed been processed, but I can do a check for that by having the other server redirect back to a URL randomly generated and sent by the test.php file. This would involve less data transfer too so the pages should load a little quicker too.

I need to sleep now, but I'll have a crack at doing that tomorrow. Hopefully it works out

If you can think of a better way for me to achieve the same effect I'd love to hear about it though!

Your form would get the required data and a unique theme name from the user and submit this to 'add.php' on your server, your server would then save this to the database. Of course this could quite easily be a local file, or as hinted at, a post-processed theme based on the submitted values.

The user would then just add 'style.php' as the src for a style element on their page, along with defining the RYAN_APP_THEME_KEY constant inside it.

This would require the user to edit this file each time a new theme was created though, if you had a username / password combo though, you could pass these instead and load the latest CSS created.

style.php would obtain the data returned by getCSS.php located on your server and output it as CSS based on the theme key.

You solved another problem I didn't realise I was about to have! It hadn't occured to me that I didn't have a way to access the data from the processing server directly.

I actually modified the method you posted above quite a lot and am storing it in flat files instead. Seems to be working well though There is a few advantages for me in doing that as the way I'll have it setup may quite a few hits to the database if I went that route, whereas presumably accessing the flat file directly will load a bit quicker.