problem posting by PHP
Posted: Sat Dec 20, 2008 8:32 am
Hi,
I am new here, I am trying to achieve posting using php by writing http headers then send it to another server. I am posting in send.php and get the result by receive.php. I did get an email by this code, but it seems it cannot get the value of $sk. I get the email of content: "sk is " which is incorrect. Anyone can show me any errors inside??? i got my head cracking for several weeks now... THANK IN ADVANCE
p.s: do i need to use urldecode()??
==============================send.php============================================
<?php
echo "here....";
$sk = '5464564654';
$sk= urlencode(stripslashes($sk));
$req = "sk=".$hid;
$header .= "POST /receive.php HTTP/1.0\r\n";
$header .= "Host: http://www.host.info:80\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.host.info', 80, $errno, $errstr, 30);
if (!$fp) {
echo "error occured!!";
exit;
}
else {
fputs ($fp, $header . $req);
echo $header . $req ;
}
fclose ($fp);
?>
==============================send.php============================================
==============================receive.php===========================================
<?php
$sk = $_POST['sk'];
$mail_From = "tech@host.info";
$mail_to = "admin@gmail.com";
$mail_Subject = "confirmation";
$mail_Body = "sk is $sk" ;
mail($mail_to, $mail_Subject, $mail_Body, $mail_From);
?>
==============================receive.php===========================================
I am new here, I am trying to achieve posting using php by writing http headers then send it to another server. I am posting in send.php and get the result by receive.php. I did get an email by this code, but it seems it cannot get the value of $sk. I get the email of content: "sk is " which is incorrect. Anyone can show me any errors inside??? i got my head cracking for several weeks now... THANK IN ADVANCE
p.s: do i need to use urldecode()??
==============================send.php============================================
<?php
echo "here....";
$sk = '5464564654';
$sk= urlencode(stripslashes($sk));
$req = "sk=".$hid;
$header .= "POST /receive.php HTTP/1.0\r\n";
$header .= "Host: http://www.host.info:80\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.host.info', 80, $errno, $errstr, 30);
if (!$fp) {
echo "error occured!!";
exit;
}
else {
fputs ($fp, $header . $req);
echo $header . $req ;
}
fclose ($fp);
?>
==============================send.php============================================
==============================receive.php===========================================
<?php
$sk = $_POST['sk'];
$mail_From = "tech@host.info";
$mail_to = "admin@gmail.com";
$mail_Subject = "confirmation";
$mail_Body = "sk is $sk" ;
mail($mail_to, $mail_Subject, $mail_Body, $mail_From);
?>
==============================receive.php===========================================