/    Sign up×
Community /Pin to ProfileBookmark

automated submission of a form

<?php
$crl = curl_init();
$url = “http://localhost/parser.html“;
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($crl, CURLOPT_POST, 1);
$protinput=”protein.txt”;
$filehandle= fopen($protinput, ‘r’);
$protein = fread($filehandle, filesize($protinput));
fclose($filehandle);
$rnainput=”eg.txt”;
$filehandle= fopen($rnainput, ‘r’);
$rna = fread($filehandle, filesize($rnainput));
fclose($filehandle);

$postdata = array( “p_input” => “$protein”, “r_input” => “$rna”, “submit” => “Submit”);
curl_setopt($crl, CURLOPT_POSTFIELDS, $postdata);

$result = curl_exec($crl);
$headers = curl_getinfo($crl);
if ($headers[‘url’] == $url) {
die(“I’m dead.”);
}
return $result;
?>

so this is my php code, i’m using the curl library to send data thru a form, but it isn’t sending. Basically im using a web tool and i have to use it about 25.5 million times so obviously i need it automated. can someone please tell me what im doing wrong?

the localhost url- i checked it while making that little thing, and it works just fine when i click submit on that, but it isn’t being processed through this script.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@kbduvallJun 18.2012 — The first thing that jumps out at me is: curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

You may want to change $ch to $crl
Copy linkTweet thisAlerts:
@bsmbahamasJun 20.2012 — lol, yup that may be the problem, bythe way can any of you suggest a few good tutorials on how to use curl? i'd really like to understand how to use it
Copy linkTweet thisAlerts:
@kbduvallJun 20.2012 — cURL is pretty diverse. It can be used for just about anything. That diversity makes it hard to recommend one good tutorial because it really depends on what you want to use it for.

I would first suggest reading the php manual on it -- including the user comments. After that, you can find a plethora of good tutorials simply by googling for it.
Copy linkTweet thisAlerts:
@bsmbahamasJun 20.2012 — cURL is pretty diverse. It can be used for just about anything. That diversity makes it hard to recommend one good tutorial because it really depends on what you want to use it for.

I would first suggest reading the php manual on it -- including the user comments. After that, you can find a plethora of good tutorials simply by googling for it.[/QUOTE]


i'll look into it, i'd probably use it in a similar way to automate form submission across a bunch of sites, for example, if one wanted to submit an artile via forms on multiple sites. i realize that you'd have to write several versions.

in th epast i just settled for using autohotkey, actually had a site that dynamically generated the autohotkey code each day as different variables changed over time, so it would check to see the current state of things and then create the autohotkey file from scratch, all i'd do then was download the file from a link provided and double click it.

= )
Copy linkTweet thisAlerts:
@kbduvallJun 20.2012 — It can be used for about anything really... not just web pages. From the manual:

libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.[/QUOTE]

So you could use it to make a PHP based telnet client, proxy server, or really about anything else you want. That's why it's hard to find one good "definitive" guide to cURL.
Copy linkTweet thisAlerts:
@bsmbahamasJun 20.2012 — It can be used for about anything really... not just web pages. From the manual:

So you could use it to make a PHP based telnet client, proxy server, or really about anything else you want. That's why it's hard to find one good "definitive" guide to cURL.[/QUOTE]


wow didn't know it was that versatile, thanks for the info.
×

Success!

Help @kipal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...