PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Problems sending $_POST vairable to an ASP page
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problems sending $_POST vairable to an ASP page

Réponse
 
LinkBack Outils de la discussion
Vieux 28/08/2008, 23h17   #1
shaun thornburgh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problems sending $_POST vairable to an ASP page

Hi guys,
I need to send post variables to an ASP page. I have the following code which isn't producing any errors but isn't working either:

foreach($_POST['newsletter-group'] as $key => $value){ $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp = fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); } fclose($fp); }

Can anyone tell me what I am doing wrong please?
__________________________________________________ _______________
Get Hotmail on your mobile from Vodafone
http://clk.atdmt.com/UKM/go/107571435/direct/01/
  Réponse avec citation
Vieux 28/08/2008, 23h21   #2
Jay Blanchard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Problems sending $_POST vairable to an ASP page

[snip]
I need to send post variables to an ASP page. I have the following code
which isn't producing any errors but isn't working either:

foreach($_POST['newsletter-group'] as $key => $value){
$_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp =
fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo
"$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); }
fclose($fp); }

Can anyone tell me what I am doing wrong please?
[/snip]

http://www.php.net/curl


there was just a thread on this within the past week.
  Réponse avec citation
Vieux 28/08/2008, 23h22   #3
Ólafur Waage
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Problems sending $_POST vairable to an ASP page

IIRC ASP cant recive PHP $_POST variables but it can recive HTML post
from forms.

If you want to send variables to another language. You can try via a
get variable. Dont know if the items you want to send are safe to send
over though.

Ólafur Waage

2008/8/28 shaun thornburgh <shaunthornburgh@hotmail.com>:
> Hi guys,
> I need to send post variables to an ASP page. I have the following code which isn't producing any errors but isn't working either:
>
> foreach($_POST['newsletter-group'] as $key => $value){ $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp = fsockopen("dmtrk..net", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); } fclose($fp); }
>
> Can anyone tell me what I am doing wrong please?
> __________________________________________________ _______________
> Get Hotmail on your mobile from Vodafone
> http://clk.atdmt.com/UKM/go/107571435/direct/01/

  Réponse avec citation
Vieux 28/08/2008, 23h23   #4
shaun thornburgh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Problems sending $_POST vairable to an ASP page





> Date: Thu, 28 Aug 2008 16:21:19 -0500> From: jblanchard@pocket.com> To:shaunthornburgh@hotmail.com; php-general@lists.php.net> Subject: RE: [php] Problems sending $_POST vairable to an ASP page> > [snip]> I need to send post variables to an ASP page. I have the following code> which isn't producing any errors but isn't working either:> > foreach($_POST['newsletter-group'] as $key => $value){> $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp => fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo> "$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); }> fclose($fp); }> > Can anyone tell me what I am doing wrong please?> [/snip]> > http://www.php.net/curl> > > there was just a thread on this within the past week.> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>


Hi Jay,

Unfortunately I don't have curl installed on my server.


__________________________________________________ _______________
Make a mini you on Windows Live Messenger!
http://clk.atdmt.com/UKM/go/107571437/direct/01/
  Réponse avec citation
Vieux 28/08/2008, 23h24   #5
Jay Blanchard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Problems sending $_POST vairable to an ASP page

[snip]
Unfortunately I don't have curl installed on my server.
[/snip]

Unless you can open a socket or a curl session you will not be able to
post values to a remote page. Curl is your best bet, can it be
installed?
  Réponse avec citation
Vieux 29/08/2008, 00h01   #6
shaun thornburgh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Problems sending $_POST vairable to an ASP page



> Date: Thu, 28 Aug 2008 16:24:58 -0500> From: jblanchard@pocket.com> To:shaunthornburgh@hotmail.com; php-general@lists.php.net> Subject: RE: [php] Problems sending $_POST vairable to an ASP page> > [snip]> UnfortunatelyI don't have curl installed on my server.> [/snip]> > Unless you can open a socket or a curl session you will not be able to> post values to a remotepage. Curl is your best bet, can it be> installed?> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>

It appears I was wrong, I do have cURL installed!
__________________________________________________ _______________
Win New York holidays with Kellogg’s & Live Search
http://clk.atdmt.com/UKM/go/107571440/direct/01/
  Réponse avec citation
Vieux 29/08/2008, 09h38   #7
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Problems sending $_POST vairable to an ASP page

On 28 Aug 2008, at 22:17, shaun thornburgh wrote:
> Hi guys,
> I need to send post variables to an ASP page. I have the following
> code which isn't producing any errors but isn't working either:
>
> foreach($_POST['newsletter-group'] as $key => $value)
> { $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp
> = fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo
> "$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r
> \n"); } fclose($fp); }
>
> Can anyone tell me what I am doing wrong please?



<?php
$result = false;

// I can't see in your example where you're building the POST data,
but here's an example
$postdata = 'var='.urlencode($value);

$fp = fsockopen('dmtrk.net', 80, $errno, $errstr, 30);
if (!$fp)
{
$result = 'Connection failed: ['.$errno.'] '.$errstr;
}
else
{
fwrite($fp, "POST /signup.ashx HTTP/1.1\n");
fwrite($fp, "Connection: close\n");
fwrite($fp, "Host: dmtrk.net\n");
fwrite($fp, "Content-Length: ".strlen($postdata)."\n");
fwrite($fp, "Content-Type: application/x-www-form-urlencoded\n");
fwrite($fp, "\n".$postdata."\n");

// Get the status
$response = fgets($fp);
$result = (strpos($response, ' 200 ') !== false);

// Read the rest of the response
while (!feof($fp))
{
$response .= fgets($fp);
}
@fclose($fp);

if (!$result) $result = $response;
}

// At this point $result will either be === true or it will contain an
error message

// Please don't ask a question again without doing a reasonable amount
of research first. In this case that would be the HTTP spec and the
PHP socket function documentation. This was not difficult!
?>

-Stut

--
http://stut.net
  Réponse avec citation
Vieux 29/08/2008, 10h04   #8
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Problems sending $_POST vairable to an ASP page

On 28 Aug 2008, at 23:01, shaun thornburgh wrote:
>> Date: Thu, 28 Aug 2008 16:24:58 -0500> From: jblanchard@pocket.com>
>> To: shaunthornburgh@hotmail.com; php-general@lists.php.net>
>> Subject: RE: [php] Problems sending $_POST vairable to an ASP page>
>> > [snip]> Unfortunately I don't have curl installed on my server.>

>> [/snip]> > Unless you can open a socket or a curl session you will
>> not be able to> post values to a remote page. Curl is your best
>> bet, can it be> installed?> > -- > PHP General Mailing List (http://www.php.net/
>> )> To unsubscribe, visit: http://www.php.net/unsub.php>

> It appears I was wrong, I do have cURL installed!


In that case I'll amend my earlier answer to the following...

<?php
// I can't see in your example where you're building the POST data,
but here's an example
$postdata = 'var='.urlencode($value);

if (function_exists('curl_init'))
{
// Do it with CURL
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, 'http://dmtrk.net/signup.ashx')
;
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($curl_handle);
curl_close($curl_handle);
}
elseif (function_exists('fsockopen'))
{
$fp = fsockopen('dmtrk.net', 80, $errno, $errstr, 30);
if (!$fp)
{
$result = 'Connection failed: ['.$errno.'] '.$errstr;
}
else
{
fwrite($fp, "POST /signup.ashx HTTP/1.1\n");
fwrite($fp, "Connection: close\n");
fwrite($fp, "Host: dmtrk.net\n");
fwrite($fp, "Content-Length: ".strlen($postdata)."\n");
fwrite($fp, "Content-Type: application/x-www-form-urlencoded\n");
fwrite($fp, "\n".$postdata."\n");

// Get the status
$response = fgets($fp);
$result = (strpos($response, ' 200 ') !== false);

// Read the rest of the response
while (!feof($fp))
{
$response .= fgets($fp);
}
@fclose($fp);

if (!$result) $result = $response;
}
}
else
{
die('No suitable mechanism for POSTing available.');
}
?>

Note that I've not tested this at all, but it should work. Also it
would be better wrapped up in a function, but unfortunately I have
real work to do today.

-Stut

--
http://stut.net/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h15.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14983 seconds with 16 queries