can any body pls explain me why does the below function does not work in Yii
i want to run a php page from background with get or post method..
in simple, sending aruguments in url and do some work in background..
for that purpose after having soo much of research, i found a function which simply does that, but still it doesnt work with YII..
the function..
function backgroundPost($url){
$parts=parse_url($url);
$fp = fsockopen($parts['host'],
isset($parts['port'])?$parts['port']:80,
$errno, $errstr, 30);
if (!$fp) {
return false;
} else {
$out = "POST ".$parts['path']." HTTP/1.1\r\n";
$out.= "Host: ".$parts['host']."\r\n";
$out.= "Content-Type: application/x-www-form-urlencoded\r\n";
$out.= "Content-Length: ".strlen($parts['query'])."\r\n";
$out.= "Connection: Close\r\n\r\n";
if (isset($parts['query'])) $out.= $parts['query'];
fwrite($fp, $out);
fclose($fp);
return true;
}
}usage of function.. (after form validates)
$url = Yii::app()->params['hostname'].'/index.php/admin/vendor/notification?salesrep='.$vendors->sales_rep_id; $this->backgroundPost($url);
in the action..
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$salesRep = User::model()->findByPk($_POST['salesrep']);
mail('$salesRep->email', 'My Subject', 'Message body', $headers);
exit;any help is really appreciated. tnx

Help













