简体   繁体   中英

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 submit 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.

简短的回答是curl可以满足我的需要,需要:

 `curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM