Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

curl write to a remote textbox and press submit button

Posted on 2013-02-03
2
Medium Priority
?
1,119 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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…
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…
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.
Suggested Courses

610 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