I have in my site a form which is sent to another domain's web page.
The action is defined as: action="htpps://xxxxxxx.com/pagename".
I need to modify this as follows:
When 'submit' is pressed, I want to have 2 actions:
1. Send the form data to the predefied web page.
2. Email the form data to my email address.
I tried curl php code as shown below:
$ch = curl_init("htpps://xxxxxxx.com/pagename");
$params = '';
// include POST variables.
foreach($_POST as $name => $value) {
$params .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$params = substr($params, 0, strlen($params)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$response = curl_exec($ch);
curl_close($ch);
To my misfortune, the data was not sent to htpps://xxxxxxx.com/pagename.
I then tried http_post function, a php code as shown below, and this, too did not work.
function HTTP_Post($URL,$data, $referrer="") {
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=$_SERVER["REQUEST_URI"];
// making string from $data
foreach($data as $key=>$value)
$values[]="$key=".urlencode($value);
$data_string=implode("&",$values);
// Find out which port is needed - if not given use standard (=80)
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;
$request = "";
// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";
$result = "";
$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);
return $result;
}
Any suggestions?
Thanks all,
Get 2 actions from single form "submit"
Moderator: General Moderators
Re: Get 2 actions from single form "submit"
You should post the data to your page to email you, then in your script re-post that data to the forms action page.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.