Submitting a form after processing in PHP
we have a form that grabs a whole bunch of details and then submits it to a mail program which send an email to certain people.
I need to put some extra processing between the form and mail program which checks info from a db and then changes the form data accordingly.
I thought I would be able to use curl for this but once I do the processing I need to su开发者_JAVA技巧bmit the form and have things run the way they would as if the php wasn't there and it seems I can't do this with curl.
Question is can I do this with curl? Or is there a better way to go about this. (although I can do minor changes to both the mail and form they should stay the same as much as possible).
Edit: I'm not sure what information I can put in but I'll try and simplify it.
At the moment: form -> mail program
What I am trying to do: form -> php ->mail program
Mail program takes POST variables so what I want to do is grab the post variables, change some of them and then send them to the mail program and the previous process looks the same.
Use this:
http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/
<?php
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
Requires PHP5. Arrange all the data you need in PHP and stream out the post values.
make the PHP file to generate a form with the attribute filled with processed value. then you use Javascript to submit the form in the end.
Short answer was curl can do it for what I need, needed:
`curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);`
精彩评论