Page 1 of 1

submit form to other site... in background (or whatever)?

Posted: Wed Apr 27, 2005 10:49 pm
by Skara
Ok, here's what I need to figure out how to do.
I need to be able to fill out a form that submits the data to one site, then redirects (or whatever) to another site.
In other words...
> I fill out form.
> I click submit.
> Data goes to foo.com/page.php
> I go to bar.com

This possible?

Posted: Wed Apr 27, 2005 10:59 pm
by partiallynothing
Try looking into the header function http://php.net/header

Here is an example:

Code: Select all

<?php
// Process post data
header('Location: http://bar.com/'); // Redirect user
?>

Posted: Wed Apr 27, 2005 11:16 pm
by Skara
ok, but how would I send the data somewhere else? There are three locations here: my script, the site the data is sent to, and where I'm redirected to. In other words, I need something like this:

if (submitted) {
send code
redirect
} else print(form);

re

Posted: Wed Apr 27, 2005 11:35 pm
by harrisonad
yourform.php submit to processing.php, then processing.php will redirect it to otherplace.php

dig it

Posted: Thu Apr 28, 2005 11:39 am
by Skara
ok, you guys still aren't getting what I mean... Ok, let me re-explain yet again.

I have control over page A. page B is NOT under my control in any way. the same for page C.
In other words, it might look like this:

me.com/form.php =>DATA=> foo.com/processing.php
\\=>REDIRECT=> bar.com/view.php

Again, I have no control over the page I want the data sent to. :/

Posted: Thu Apr 28, 2005 11:50 am
by jmrdeuce32
Where is the data going in the page you are sending it to?...Does it know to look for the data?....Does the data change between the first and second pages?...

If the second page is accepting dat use variables like $_POST or $_GET depending on what the page is looking for.

I don't know how you would be redirected from the second page to the third if you don't have any control over the second.

You may be able to have the form open a new window with the second page as well as redirect to the third page in the main window.

Posted: Thu Apr 28, 2005 12:24 pm
by John Cartwright
set the action to the site you want it to go to. This can be dynamically changed with javascript.

You can always use curl()

Posted: Thu Apr 28, 2005 3:49 pm
by Skara
ok, curl's giving me a headache. Does this look anything close to right?

Code: Select all

$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,"http://foo.com/process.php");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "var={$_GET['var']}");
  curl_exec($ch);
  curl_close($ch);

Posted: Thu Apr 28, 2005 4:07 pm
by xisle
just pop a new window and target the post to the new window

Code: Select all

<script language=&quote;Javascript&quote;>
<!-- //
function popIt(){
    window.open('','windowfoo','toolbar=0,menubar=0,scrollbars=0,resizable=0,width=1,height=1');
    document.theform.target = 'windowfoo';
    document.theform.submit();
}
// -->
</script>

Posted: Thu Apr 28, 2005 4:23 pm
by Skara
yes, but I don't want to SEE the processing page... That's the whole point of this script. ;)