Solved

curl write to a remote textbox and press submit button

Posted on 2013-02-03
2
1,020 Views
Last Modified: 2013-02-04
http://hrblock.host22.com/output.html
output written to this file

http://hrblock.host22.com/order.html
<html><body>
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post"> 
<select name="item"> 
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" /> 
<input type="submit" />
</form>
</body></html>

Open in new window



http://hrblock.host22.com/process.php
<html><body>
<?php

$myFile = "output.html";
$fh = fopen($myFile, 'a');

$quantity = $_POST['quantity'];
$item = $_POST['item'];




$output= "On ".(date("D F d H:i:s",time()))." , You ordered ". $quantity . " " . $item . ".<br />";
fwrite($fh, $output);
echo $output;
?>
</body></html>

Open in new window




This may use curl

Could you please create a php script to write to
order.html textbox
<input name="quantity" type="text" />
 and press submit button
0
Comment
Question by:rgb192
[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 Comments
 
LVL 5

Accepted Solution

by:
Php_expert earned 500 total points
ID: 38850030
<?php
 define('POSTURL', 'http://hrblock.host22.com/process.php');
 define('POSTVARS', 'quantity=2&item=paint');  // POST VARIABLES TO BE SENT
 
 $ch = curl_init(POSTURL);
 curl_setopt($ch, CURLOPT_POST      ,1);
 curl_setopt($ch, CURLOPT_POSTFIELDS    ,POSTVARS);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
 curl_setopt($ch, CURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS
 curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
 $Rec_Data = curl_exec($ch);

 curl_close($ch);

exit;
?>

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 38851453
works great
sends the post

thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.

732 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