Using PHP can you create a pseudo form submit without ever generating a form? Just initialize and declare variables and them pass them to another page via the POST or GET methods?
Definitely. You can do this using cURL, this link should explain the basics: http://curl.haxx.se/docs/httpscripting.html - but there are hundreds of cURL tutorials on the internet for doing things like this.
Once you get the hang of cURL, it's quite easy to understand and use.
Here is a code example:
<?
define('POSTURL', 'http://www.test.com/search.php');
define('POSTVARS', 'listID=29&request=suba&SubscribeSubmit=Subscribe&EmailAddress=');// POST VARIABLES TO BE SENT
$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVARS);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
$data = curl_exec($ch);
?>
Something like that should work.
What you're looking for is cURL, a library for creating such requests.
Theoretically, you could generate internal requests in Apache for this form submission; in practice, you'll have to use PHP's http stream wrapper or curl, like the others suggested.
You can try doing something like this
$_POST = array(
'lname'=>urlencode($last_name),
'fname'=>urlencode($first_name),
'title'=>urlencode($title),
'company'=>urlencode($institution),
'age'=>urlencode($age),
'email'=>urlencode($email),
'phone'=>urlencode($phone)
);
$_GET = array(); // no get
$_SERVER['REQUEST_METHOD'] = "POST";
$_SERVER['REQUEST_URI'] = '/anotherpage.php';
// set REQUEST_PATH, REQUEST_PATHINFO, REQUEST_SCRIPTNAME etc
// now it will be like this anotherpage.php was requested with a form
include("anotherpage.php");
If you want to avoid cURL but I don't recommend it because it gets messy fast.
I am not sure if you can set POST options, but as long as GET is acceptable you could do this very easily (i'm not expert enough to rattle this off without testing and promise no bugs, so you'll have to test):
$url = "http://foo.com?"
while(list($key, $value) = each($_POST)
$url .= "$key" . "=" . $value . "&";
header(Location: $url);
This will turn your POST into a GET.