Jump to content

[SOLVED] Repost $_POST


papaface

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/70562-solved-repost-_post/
Share on other sites

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>";



?>

Link to comment
https://forums.phpfreaks.com/topic/70562-solved-repost-_post/#findComment-354655
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.