views:

57

answers:

1

Basically I hate a satellite website that is including form.php from an entirely different server.

<?php
    include("http://blah.com/form.php");
?>

The form.php on the other sessions loads classes and all kinds of other things and generates a form dynamically based on a ton of MySQL data. Unimportant. My issue is that when the form is called I also start a session. Yet the remote server is not actually ever visited by the client. The session what stay. Every time the page is refreshed the old session is being dumped.

The whole reason for this is I need to send back validation errors to the original form and have them display. (It's an array of things like "First name is a required field")

The code on the main server looks something like this...

<?php
    include("config.php"); // This is loading the config file with the session_start()
    Process($id) {
        // Do a bunch of form processing and store errors in $this->errors
        $_SESSION['errors'] = $this->errors;
    }

    ShowForm($id) {
        // This loads the form and everything.
        echo '<div id="errors">'.print_r($_SESSION['errors']).'</div>'; // This is what is returning nothing on the other page.
    }
?>

So basically that script is called from the remote site, but the sessions won't save and are dumped on refresh... I assume its because the actualy main server is never loaded in the users browser.

Does anyone know a way around this/a way to fix this? Or possibly a different solution? Anything works.

Thanks

A: 

that's indeed terrible design.

include("http://blah.com/form.php?var=1&amp;error=First%20name%20is%20a%20required%20field");

you have to think of XMLRPC or some other civilized way of data interchange

Col. Shrapnel
Bleh yeah it is but for the project is pretty much neccesary. I want to take as much work as possible out of the affiliates hands when they set up a lead form if you get what I mean. We set up the campaign, give them an include, and the rest is taken care of. I was trying to avoid a GET xD
sct
@sct better try to realize what HTTP protocol is and how it works. it will save you hours of finding non-existent solution
Col. Shrapnel
Okay. I will look into it right now. Thanks.
sct
@sct though you're right. it is because main site never being loaded in the browser. And, because session consists of an identifier and a file, a satellite server session cannot be accessed from the main one. So, the only way to pass the data is regular HTTP request - GET or POST.
Col. Shrapnel