Solved

php similiar in Perl lwp:useragent

Posted on 2004-03-30
5
1,229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple function not working 7 44
Unwanted output from my query 5 40
How would I craft a PDO SELECT based on an IF Statement? 8 30
How do use '  ' within this code? 4 27
This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

749 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