papaface Posted September 25, 2007 Share Posted September 25, 2007 Hi, Could someone tell me if it is possible to do this scenario? Mike fills in a form on abc.com. He submits the form. The form is POSTED to 123.com. 123.com checks one field name in the $_POST array. 123.com then wants to POST the variables that were POSTED by abc.com to qwerty.com so that they can check the $_POST values. Is that possible? regards Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/ Share on other sites More sharing options...
trq Posted September 25, 2007 Share Posted September 25, 2007 Yes. Take a look at the curl extension. Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354574 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 Thanks for the quick reply! Any help on how I would repost the entire $_POST array? I still need to learn cURL, hence why I didn't know you could do it lol. Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354576 Share on other sites More sharing options...
trq Posted September 25, 2007 Share Posted September 25, 2007 At its simplest, something like.... <?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://qwerty.com"); curl_setopt($curl, CURLOPT_POST, $_POST); curl_exec($curl); curl_close($curl); ?> Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354578 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354599 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 I want abc.com to POST the $_POST vars to qwerty.com, but I want the page to actually go there aswell. Is that possible? The example above doesn't seem to do that... Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354645 Share on other sites More sharing options...
Psycho Posted September 25, 2007 Share Posted September 25, 2007 There might be an easier solution, but one way to do it would be to have the receiving page on abc.com to first do it's validation and then create a new form (with the target pointing to the receiving page of qwerty.com) with hidden fields named the same as in the original form, populated with the values, and then auto-submit the page as soon as it loads using javascript. At most the user would see a blank white page for about 1/2 second. Example: <?php echo "<script type=\"text/javascript\"> function submitForm() { if (document.formName) { document.formName.submit(); } } </script>"; echo "<body onload=\"submitForm()\";>"; if (!isset($_POST['submit'])) { echo "No form submited"; exit; } //Perform validation here echo "<form name=\"formName\" action=\"http://www.qwerty.com\" method=\"POST\">"; foreach ($_POST as $name => $value) { echo "<input type=\"hidden\" name=\"$name\" value=\"$value\">"; } echo "</form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354655 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 Unfortunately I need the POST vars and the page to go to qwerty.com from 123.com just as if someone has submitted the form at abc.com Quote Link to comment https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.