Solved

php similiar in Perl lwp:useragent

Posted on 2004-03-30
5
1,217 Views
Last Modified: 2012-06-21
i need find out if there is something similiar to perl lwp:useragent..

what i need is to send a form out to a server...

<form action = "https://www.test.com/index.php">
<input type = "hidden" name="test" value="testvalue">
<input type = "submit">
</form>

thus, i need to translate into

https://www.test.com/index.php?test=testvalue and send this url dynamically.
note that i am using https:...

i don't think fopen will work in this case...

any help will be great.   thanks
0
Comment
Question by:bionicblakey
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10716048

why dont you just say

<form action = "https://www.test.com/index.php?test=testvalue">
<input type = "submit">
</form>
0
 

Author Comment

by:bionicblakey
ID: 10716134
basically i am getting auto response from a server.

based on the server i need to pass the value out..

it is all dynamica and internal.

no human users will be involve....

thus no human will click on the submit to send the form.

i need the computer to send out the form...

i hope that i clearified it...

0
 
LVL 4

Accepted Solution

by:
duerra earned 500 total points
ID: 10716248
Look into cURL.  
http://www.php.net/curl

Also, if you want to do a post yourself, the user comments on http://php.net/fsockopen are really nice.

Here's a comment that looks like it would work out well, this one specifically connects SSL:

$host = "somehost.somedomain.com";
$port = 443;
$path = "/the/url/path/file.php"; //or .dll, etc. for authnet, etc.

//you will need to setup an array of fields to post with
//then create the post string
$formdata = array ( "x_field" => "somevalue");
//build the post string
  foreach($formdata AS $key => $val){
   $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
  }
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);

$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
 //error tell us
 echo "$errstr ($errno)\n";
   
}else{

  //send the server request
  fputs($fp, "POST $path HTTP/1.1\r\n");
  fputs($fp, "Host: $host\r\n");
  fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
  fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
  fputs($fp, "Connection: close\r\n\r\n");
  fputs($fp, $poststring . "\r\n\r\n");

  //loop through the response from the server
  while(!feof($fp)) {
   echo fgets($fp, 4096);
  }
  //close fp - we are done with it
  fclose($fp);
}
0
 

Author Comment

by:bionicblakey
ID: 10716307
thanks duerra.  the curl looks great...
0
 
LVL 4

Expert Comment

by:duerra
ID: 10716338
No prob
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now