Solved

php similiar in Perl lwp:useragent

Posted on 2004-03-30
5
1,211 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

16 Experts available now in Live!

Get 1:1 Help Now