Page 1 of 1

$_POST to two PHP pages simultaneously !?

Posted: Thu Jun 23, 2005 10:31 am
by Hebbs
Hey everyone,

I have a webpage that is basically a form.

The form spawns a '_new' page which generates a pdf document for printing and is then closed by the user.

I normally do error checking on the webpage by either JS or checking values on the next page, however, this is difficult in this instance as I use a JS 'onSubmit' command to return the user to the homepage on the submission of the form. It appears one cant combine two JS commands on one onSubmit so I cant check errors and forward the page at the same time.

What I need do know is this...

How can I $_POST values to two pages at the same time?

I need to forward 3 or 4 $_POST values to the '_new' window to complete the PDF form and send the same to the home page to ensure the values have been completed (error checking).

I have belted the net looking for a JS solution, but not being a JS wiz in any way shape or form, havent been able to come up with an answer. :oops:

Unfortunately this is the only solution I can come up with - double checking. If the value/s are not set in the '_new' page I instantly kill the page and the user is left with an error message on the homepage, hits the 'Back' button and returns to the form - if only I can $_POST them there that is.

I have lost a day and a half on this and am just about at my wits end!

All thoughts and suggestions most welcome - hopefully before I go completely loopy :?

Regards

Hebbs

Posted: Thu Jun 23, 2005 10:51 am
by Burrito
you can't actually POST to two different pages at the same time:

I see a few different options for you:

1) include one of the two pages on your action page with include()
2) brush up on your js to do more with your onSubmit, specifically, open a new window before it submits or alternatives

as I didn't fully understand what you're trying to do it's difficult to say what would be the best solution for you. If you just need to generate a pdf "in the background", I'd use the include option on your action page and just include the pdf page above any other processing.

Posted: Thu Jun 23, 2005 10:59 am
by Hebbs
Hmmm,

How best to explain this....

The form submission is part of a work flow process of 3 pages, it is the last step that generates an invoice (the pdf). I didnt want to create the pdf in the same window and have to back out etc so thats why it creates as a '_new' window, is printed then closed.

Rather than 'back' out of the completed form, or have a button I wanted the page to automatically return to a main page which displays completed invoices and their status etc.

All of this I can do, but not the dumb person check bits to ensure the fields have been completed, before it goes back to the main page. Hence my desire to error check on the main page.

I gotta tell ya, I dont lurve JS not even a little bit so if I can find a PHP solution.... :twisted:

Hebbs

Posted: Thu Jun 23, 2005 11:14 am
by Burrito
so I still dont' understand why you couldn't just include the pdf generation on the action page if all of the required fields are entered.

Code: Select all

if($required)
   include("pdf-generator.php");
else
   header("Location: form-page.php");
if it HAS to be on a different page, you could include a hidden IFRAME and process the invoice from there.