Hey Everyone,
Was wondering if you could give me some insight on a task I am trying to accomplish.
My boss has told me to modify a form script I wrote almost 2 years ago, and put it into 2 pages. For some reason, the marketing dept. wants this form in 2 pages for some odd reason.
Well one stipulation to it, is they want information from page 1 sent off, even if they close the page before submitting part 2 of the form on page 2.
My boss said do not use databases, at least for now. So I'm trying to think of a way to make this work.
Now the way my boss initially wanted it to work is if the visitor closes the page, then have the e-mail sent off, but only then. And because closing a browser window is a client side event, and not a server event, client side scripting is the only way to make it work that I can think of. I tried nosing around to see if PHP had any function at all that could handle something like that, and either it doesn't exist, or I just wasn't finding it.
So, I tried using the JavaScript onUnload event, and calling a JS function that I placed in <head>, which the function called a PHP function using document.write. I was sure that wouldn't work, but thought it was worth a shot none the less. And of course, it didn't work.
So another approach I tried was sending two e-mails, but my boss doesn't like that idea, and the session variables I created do not seem to like being sent off twice anyway. One e-mail will contain only part of the data, and the second e-mail will have the rest (when both pages are submitted), but not necessarily in the proper order of forms.
I thought about trying a cookie, but cookies are loaded when the page loads, much like sessions and session variables. Therefore I am almost completely positive there is no way to store the variables to a cookie from the same page like that.
So I am just out of ideas here how to make this work. If someone could guide me in the right direction, that'd be awesome.
Thanks in advance for your help. 🙂