Solved

curl write to a remote textbox and press submit button

Posted on 2013-02-03
2
976 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 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