?
Solved

php similiar in Perl lwp:useragent

Posted on 2004-03-30
5
Medium Priority
?
1,240 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 2000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

777 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