0

I've got two files. Let's call them a.php and b.php. In a.php, I want to show the result of b.php, when post data is submitted to this b.php.
If it's not totally clear yet, here's what the files kind of look like.

a.php:

$one = "apple";
$two = "pear";
$three = "phone";

$array = array(
        "one" => $one,
        "two" => $two,
        "three" => $three
);

$string = postformdataintoafile($array, "b.php");

Obviously, postformdataintoafile() is not a real function, but I hope you get the idea. So, what I would like to know is how this is going to work and with what functions I should do it.

And $string should actually be the whole HTML-page, that is created.

If anyone could help me with this, it would be very appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Citoshi
  • 17
  • 2

1 Answers1

0

This is a classic AJAX situation.

The file b.php is what we call the AJAX processor.

Use js/jQuery to collect the field values, and then an AJAX construct to submit them to b.php.

After processing, b.php uses the PHP echo command to return the results to a.php, where they appear in the success function of the AJAX routine.

Here is a post that gives some simple examples:

AJAX request callback using jQuery

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111